1.0.1 • Published 3 years ago
react-frex-state v1.0.1
react-frex-state
A painless react state library. Document
Useage
Install library
$ npm i react-frex-stateCreate 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 iStart the dev server,
$ npm startBuild documentation,
$ npm run docs:buildRun test,
$ npm testBuild library via father,
$ npm run build