Skip to content

ArthurYung/react-frex-state

Repository files navigation

react-frex-state

A painless react state library. Document

codecov npm listener

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

About

A painless react state library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published