Skip to content
marek edited this page Sep 16, 2025 · 4 revisions

Menu & MenuProvider

TBD

How to edit page-specific menu item:

const { deleteRootMenuItem, addRootMenuItem } = useMenu();
const item = createNewRootMenuItem();
useEffect(() => {
    addRootMenuItem(item );
    return () => {
        deleteRootMenuItem(item .id);
    };
}, []);

How to delete an item from the menu for a given page:

const { retrieveIdByTitle, deleteRootMenuItem, addRootMenuItem } = useMenu();
const deletedRef = useRef<RootMenuItem | undefined>(undefined);

useEffect(() => {
    const id = retrieveIdByTitle("Help");
    if (id) {
        deletedRef.current = deleteRootMenuItem(id);
    }
}, [retrieveIdByTitle, deleteRootMenuItem]);

useEffect(() => {
    return () => {
       if (deletedRef.current) {
           addRootMenuItem(deletedRef.current);
       }
   };
}, []);

Clone this wiki locally