mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-08-13 12:00:10 +02:00
24 lines
688 B
TypeScript
24 lines
688 B
TypeScript
import { createContext, Dispatch, FC, SetStateAction, useState } from 'react'
|
|
|
|
export type NestableDropdownContextType = {
|
|
selected: string | null
|
|
setSelected: Dispatch<SetStateAction<string | null>>
|
|
menuId: string
|
|
}
|
|
|
|
export const NestableDropdownContext = createContext<
|
|
NestableDropdownContextType | undefined
|
|
>(undefined)
|
|
|
|
export const NestableDropdownContextProvider: FC<
|
|
React.PropsWithChildren<{ id: string }>
|
|
> = ({ id, children }) => {
|
|
const [selected, setSelected] = useState<string | null>(null)
|
|
return (
|
|
<NestableDropdownContext.Provider
|
|
value={{ selected, setSelected, menuId: id }}
|
|
>
|
|
{children}
|
|
</NestableDropdownContext.Provider>
|
|
)
|
|
}
|