Skip to content

hyposlasher/qwark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages