Skip to content

state-management/react-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Example with State Machine

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 fromState hook.
  • Dispatching commands using the useDispatcher hook.
  • Unit testing React components with setupMockStateMachine.

The state-machine-react is a React-specific wrapper for the core library, simple-state-machine.

Features

  • 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 fromState and useDispatcher hooks for managing state in React.
  • Unit Testing: Demonstrates how to mock the state machine using setupMockStateMachine for testing.

Prerequisites

Make sure you have the following installed:

  • Node.js (16.x or later)
  • npm (8.x or later)

Getting Started

1. Install Dependencies

Clone the repository and install the required dependencies:

npm install

2. Run the application

npm run start

3. Run the unit tests

npm run test

About

A sample project demonstrating the simple state machine implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published