Predictable state management using finite state machines. Perfect for complex UI flows.
Demo coming soon...
const toggleMachine = createMachine({
id: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: { TOGGLE: 'active' }
},
active: {
on: { TOGGLE: 'inactive' }
}
}
})
const Toggle = () => {
const [state, send] = useMachine(toggleMachine)
return (
<button onClick={() => send('TOGGLE')}>
{state.value}
</button>
)
}