Creates a React context + hook pair bound to a StateMachine instance. Returns a [Provider, useHook] tuple — rename to fit your domain.
[Provider, useHook]
const machine = new StateMachine({ ... }); export const [GameProvider, useGame] = createStateMachineContext(machine); // In your app: <GameProvider><App /></GameProvider> // In components: const { state, send } = useGame(); const score = useGame((ctx) => ctx.score); // with selector Copy
const machine = new StateMachine({ ... }); export const [GameProvider, useGame] = createStateMachineContext(machine); // In your app: <GameProvider><App /></GameProvider> // In components: const { state, send } = useGame(); const score = useGame((ctx) => ctx.score); // with selector
Creates a React context + hook pair bound to a StateMachine instance. Returns a
[Provider, useHook]tuple — rename to fit your domain.