qwark
TypeScript icon, indicating that this package has built-in type declarations

1.0.10 • Public • Published

the simpliest way to make useState global

Demo

qwark creates a global useState hook. No Context. No Providers. With useState-like API

Installation

npm install qwark

or yarn:

yarn add qwark

Usage

Create qwark hook

import qwark from "qwark";

const useCountQwark = qwark(0); // call with initial state

Use 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>;
};

Package Sidebar

Install

npm i qwark

Weekly Downloads

9

Version

1.0.10

License

ISC

Unpacked Size

2.45 kB

Total Files

4

Last publish

Collaborators

  • hyposlasher