2
0
Files
bot/apps/builder/contexts/EditorContext.tsx

36 lines
725 B
TypeScript
Raw Normal View History

import {
createContext,
Dispatch,
ReactNode,
SetStateAction,
useContext,
useState,
} from 'react'
export enum RightPanel {
PREVIEW,
}
const editorContext = createContext<{
rightPanel?: RightPanel
setRightPanel: Dispatch<SetStateAction<RightPanel | undefined>>
2022-01-15 17:30:20 +01:00
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
}>({})
export const EditorContext = ({ children }: { children: ReactNode }) => {
const [rightPanel, setRightPanel] = useState<RightPanel>()
return (
<editorContext.Provider
value={{
rightPanel,
setRightPanel,
}}
>
{children}
</editorContext.Provider>
)
}
export const useEditor = () => useContext(editorContext)