react-robot

1.2.0 • Public • Published

react-robot

React hooks for use with Robot finite state machines.

See documentation on the website.

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>
  `;
}

License

BSD-2-Clause

/react-robot/

    Package Sidebar

    Install

    npm i react-robot

    Weekly Downloads

    3,432

    Version

    1.2.0

    License

    BSD-2-Clause

    Unpacked Size

    2.65 kB

    Total Files

    4

    Last publish

    Collaborators

    • matthewp