Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.
/ react-state-builder Public archive

A simple framework for building your application state

License

Notifications You must be signed in to change notification settings

LSVH/react-state-builder

Repository files navigation

react-state-builder

A simple framework for building your application state

NPM JavaScript Style Guide Build Status

Install

npm install --save react-state-builder

Usage

import * as React from 'react'
import createReactStateBuilder, {onLoadAction} from 'react-state-builder'

export const [context, Provider] = createReactStateBuilder({
    onInit, onLoad, canAddPayload
});

function ChildComponent() {
    const {state, dispatch} = React.useContext(context);
    const onClick = () => dispatch(onLoadAction('foo', 'bar'));
    return (
        <div>
            <h1>Current state</h1>
            <code>{JSON.stringify(state)}</code>
            <button onClick={onClick}>Update state</button>
        </div>
    );
}

export default () => (
    <Provider>
        <ChildComponent />
    </Provider>
);

Documentation

The documentation with live examples can be found in the storybook.

Roadmap

  • Add ESLint to enhance the code style.
  • Add CI tools and tests.

License

MIT © LSVH