react-robot
Version:
React hooks for Robot finite state machines
38 lines (28 loc) • 1.02 kB
Markdown
[](https://reactjs.org/) hooks for use with [Robot](https://thisrobot.life/) finite state machines.
See documentation on [the website](https://thisrobot.life/integrations/react-robot.html).
```js
import { useMachine } from 'react-robot';
import React from 'react';
import { createMachine, state, transition } from 'robot3';
const machine = createMachine({
one: state(
transition('next', 'two')
),
two: state()
});
function App() {
const [current, send] = useMachine(machine);
return html`
<button type="button" onClick=${() => send('next')}>
State: ${current.name}
</button>
`;
}
```
* Please star [the repository](https://github.com/matthewp/react-robot) on GitHub.
* [File an issue](https://github.com/matthewp/react-robot/issues) if you find a bug. Or better yet...
* [Submit a pull request](https://github.com/matthewp/react-robot/compare) to contribute.
BSD-2-Clause