This is an example project demonstrating how to use the state-machine-react. library with React. The project showcases:
- Subscribing to state changes using the
fromStatehook. - Dispatching commands using the
useDispatcherhook. - Unit testing React components with
setupMockStateMachine.
The state-machine-react is a React-specific wrapper for the core library, simple-state-machine.
- State Management: Powered by
@state-management/state-machine-react, this project integrates a simple yet powerful state management system. - React Hooks: Includes examples of the
fromStateanduseDispatcherhooks for managing state in React. - Unit Testing: Demonstrates how to mock the state machine using
setupMockStateMachinefor testing.
Make sure you have the following installed:
- Node.js (16.x or later)
- npm (8.x or later)
Clone the repository and install the required dependencies:
npm installnpm run startnpm run test