New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

global-hook

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-hook

A global version of the useState React hook with a simple API.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

global-hook

Build Status

A global version of React's useState hook.

See a live example here: https://codesandbox.io/s/global-hook-example-jhdn6

Usage:

import useGlobalState from 'global-hook';
const initialState = 0;

function Counter() {
  const [count, setCount] = useGlobalState(initialState, 'uniqueNamespace');
  return (
    <div>
      <span>{count}</span>
      <button onClick={() => setCount(count + 1)}>+</button>
      <button onClick={() => setCount(count - 1)}>-</button>
    </div>
  );
}

If you prefer to create your own instance, use createUseGlobalState:

import { createUseGlobalState } from 'global-hook';
export const useGlobalState = createUseGlobalState();

Keywords

react

FAQs

Package last updated on 15 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts