overleaf/services/web/frontend/js/features/ide-react/hooks/use-collapsible-panel.ts
Alf Eaton 23593f8650 [ide-react] Tidy IDE page layout components (#15953)
* Defer script loading
* Refactor loading
* Wait for project:joined
* Only mount IdePage once everything has connected
* Add useConnectionState hook and comments
* Remove placeholder components
* Move props into EditorAndSidebar
* Move props into MainLayout
* Tidy editor and sidebar components
* Lazy-load the symbol palette pane and separate the loading pane

GitOrigin-RevId: 4b721a06d6aba0ae0ec91768e6a6e29cf15e2083
2023-12-06 09:03:49 +00:00

17 lines
431 B
TypeScript

import { RefObject, useEffect } from 'react'
import { ImperativePanelHandle } from 'react-resizable-panels'
export default function useCollapsiblePanel(
panelIsOpen: boolean,
panelRef: RefObject<ImperativePanelHandle>
) {
useEffect(() => {
if (panelRef.current) {
if (panelIsOpen) {
panelRef.current.expand()
} else {
panelRef.current.collapse()
}
}
}, [panelIsOpen, panelRef])
}