Appearance
Menu Resolver 🍝
The menu resolver exports both menuMachine (which is used by other libraries internally) and resolveMenu which is documented below.
Usage
js
import { useState, useEffect } from 'react';
import { resolveMenu } from '@fingermarkglobal/menu.resolver';
const useExampleHook = () => {
const [menuState, setMenuState] = useState();
useEffect(() => {
if (menuState) return;
// Returns function to send commands to the machine
const run = resolveMenu({
transition: machine => setMenuState(machine),
});
run({
event: 'INITIALISE',
config: {
//...
},
});
}, [menuState, setMenuState]);
};