Skip to content

sammysaglam/react-statey

Repository files navigation

react-statey

Yet another tiny & simple global state-manager. Less than 1 KB (minified).

No redux, no context, no verbose boilerplates. TypeScript support.

Demo

Click here for Demo

Usage example

npm i react-statey
import { createState } from 'react-statey';

// this creates a global state hook, and can be used globally throughout the app
const useCounterState = createState(0);

const YourComponentA = () => {
  const [counter, setCounter] = useCounterState();

  return (
    <button onClick={() => setCounter(counter + 1)}>
      Value is {counter}
    </button>
  );
};

const YourComponentB = () => {
  const [counter, setCounter] = useCounterState();

  return (
    <button onClick={() => setCounter(counter + 1)}>
      Value is {counter}
    </button>
  );
};

License

react-statey is MIT licensed.

About

Simple global state hook

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published