useMenuContext
Hook to access the nearest Menu compound-component context
Import
import { useMenuContext } from "@videojs/react";Usage
Use this hook to build a custom part rendered inside Menu.Root.
function CloseMenuButton() {
const { menu } = useMenuContext();
return <button onClick={() => menu.close()}>Close menu</button>;
}The hook throws when there is no surrounding Menu.Root.
API Reference
Return Value
| Property | Type | Details |
|---|---|---|
core | MenuCore | |
menu | object | |
| ||
parent | object | |
| ||
state | MenuState | |
preferredSide | MenuState['side'] | |
setPositionedSide | function | |
| ||
contentId | string | |
anchorName | string | |
boundary | 'viewport' | 'container' | string & o... | |
| ||
container | object | null | |