Use An XState Machine With React
There are a bunch of well-constructed XState machines available to directly copy into your project from XState Catalogue. For instance, I can grab the Confirmation Dialog machine and paste it into confirmMachine.js
. Then I can grab @xstate/react
which comes with a useMachine
hook.
The useMachine
call both interprets and starts up the machine service. The current
value is everything about the current state of the machine. The send
is a function for dispatching transitions between machine states.
Last updated