context
Description
Optional. A context object related to the clicked menu itemUsage
context?: any;
Example
function Example({ options }) {
const [active, setActive] = useState({});
function handleClick(detail: { context: string; action?: { id: string } }) {
const { context, action } = detail;
if (action) {
setActive(prev => ({ ...prev, [context]: action.id }));
}
}
return <Menu options={options} onClick={handleClick} />;
}
Details
When a user clicks on an item, Menu calls the onClick prop. The handler is invoked with an object related to the clicked menu item (for example: { context, action }
).