Yet another tiny & simple global state-manager. Less than 1 KB (minified).
No redux, no context, no verbose boilerplates. TypeScript support.
npm i react-stateyimport { 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>
);
};react-statey is MIT licensed.