npm.io
1.1.0 • Published 1 year ago

preact-robot

Licence
BSD-2-Clause
Version
1.1.0
Deps
2
Size
3 kB
Vulns
0
Weekly
0
Stars
2

preact-robot

Preact hooks for use with Robot.

See documentation on the website.

import { useMachine } from 'preact-robot';
import { h } from 'preact';
import { html } from 'htm/prect';
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>
  `;
}

Documentation

License

BSD-2-Clause

Keywords