react-frex-state
v1.0.1
Published
A painless react state library
Downloads
1
Readme
react-frex-state
A painless react state library. Document
Useage
Install library
$ npm i react-frex-state
Create a Frex State
// store/example.ts
import { createFrexState } from 'react-frex-state';
const { context, useState } = createFrexState({
initState: {
foo: 0,
},
});
export const useExampleState = useState;
export const exampleContext = context;
Use state with hooks
// components/Demo.tsx
import { useExampleState } from 'store/example';
const Demo = () => {
const [state, setState] = useExampleState();
return <span>{state.foo}</span>;
};
Use state whit context
import { exampleContext } from 'store/example';
exampleContext.setState({ foo: 3 });
Develop
Install dependencies
$ npm i
Start the dev server,
$ npm start
Build documentation,
$ npm run docs:build
Run test,
$ npm test
Build library via father
,
$ npm run build