npm.io
1.0.1 • Published 3 years ago

usegstate

Licence
MIT
Version
1.0.1
Deps
0
Size
18 kB
Vulns
0
Weekly
0
Stars
3

usegstate

The simplest way to create Global States.

NPM JavaScript Style Guide

Install

npm install --save usegstate

Usage

Create Global State
import { gState } from 'usegstate'

const myGlobalState = gState('hello-world!')
Use Global State
import useGState from 'usegstate'

const GenderGetter = () => {
  const [gState,setGState] = useGState(myGlobalState)
  return (
    <div>{gState}</div>
  )
}
Don't forget to wrap your app inside GStateProvider
import {GStateProvider} from 'usegstate'

const Wrapper = () => {
  return (
    <GStateProvider>
      <YourWonderfullApp />
    </GStateProvider>
  )
}

License

MIT amit231