@simple-state-machine/react
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-alpha.3 • Public • Published

react

Installation

    npm i @simple-state-machine/core @simple-state-machine/react

Quick Glance

    import {useMachine} from '@simple-state-machine/react'
    import ThemeMachine from './theme-machine';

    function Theme({children}){
        const {state, send} = useMachine(ThemeMachine)
        const themeClassName = state.value === 'light' ? 'light-mode' : 'dark-mode'
        const toggleTheme = () => send('TOGGLE');

        return (
            <>
                <button onClick={toggleTheme}>Toggle Theme</button>
                <div className={themeClassName}>
                    {children}
                </div>
            </>
        )
    }

API

  • If you are new to simple-state-machine, it is recommended to go through the core package
  • In order to understand the API in depth, please go through the api-documentation

Examples

Tutorial

Package Sidebar

Install

npm i @simple-state-machine/react

Weekly Downloads

26

Version

0.1.0-alpha.3

License

MIT

Unpacked Size

22.6 kB

Total Files

5

Last publish

Collaborators

  • akhil_001