1.0.1 • Published 2 years ago

react-frex-state v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

react-frex-state

A painless react state library. Document

codecov npm

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