Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Latest commit

 

History

History
53 lines (38 loc) · 1.4 KB

README.md

File metadata and controls

53 lines (38 loc) · 1.4 KB

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