A simple framework for building your application state
npm install --save react-state-builder
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>
);
The documentation with live examples can be found in the storybook.
- Add ESLint to enhance the code style.
- Add CI tools and tests.
MIT © LSVH