1.0.10 • Published 3 years ago
qwark v1.0.10
the simpliest way to make useState global
qwark creates a global useState hook. No Context. No Providers. With useState-like API
Installation
npm install qwarkor yarn:
yarn add qwarkUsage
Create qwark hook
import qwark from "qwark";
const useCountQwark = qwark(0); // call with initial stateUse the created qwark hook in any React component
const Button = () => {
const [count, setCount] = useCountQwark();
return <button onClick={() => setCount(count + 1)}>Increment</button>;
};const Count = () => {
const [count] = useCountQwark();
return <p>{count}</p>;
};