1.1.3 • Published 4 years ago

usestatebot v1.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

useStateBot

A finite state machine React hook

NPM JavaScript Style Guide Travis-CI

Install

npm install --save usestatebot

or

yarn add usestatebot

Usage

import React from 'react';

import useStateBot from 'usestatebot';

const App = () => {
  const stateBot = useStateBot({
    initialState: 'idle',
    idle: { to: 'loading' },
    loading: { to: 'ready' },
    ready: {
      onEnter() {
        return console.log('I am ready');
      },
    },
  });

  return (
    <div>
      {stateBot.getState()}
      <button onClick={() => stateBot.next()}>Next State</button>
    </div>
  );
};

License

MIT © terzhang

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.0

4 years ago