Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

useComposerMenuState.ts

11 lines381 Bytes

1import { useState } from "react";
2​
3export function useComposerMenuState(hidden = false) {
4 const [open, setOpen] = useState(false);
5 // Base UI does not notify us when we close it by changing its open prop.
6 // Reset the stored state too, so revealing the trigger cannot reopen it.
7 if (hidden && open) {
8 setOpen(false);
9 }
10 return [open && !hidden, setOpen] as const;