1.0.13 • Published 1 year ago

globix v1.0.13

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

React Global State Hook

Globix is the easiest way to bring global state to your React App

Installing

npm i --save globix

Usage

Wrap your Root Component with GlobixProvider and pass optional initialValues props:

import { GlobixProvider } from 'globix';

ReactDOM.render(
  <GlobixProvider initialState={{name: 'Daron Malakian'}}>
    <App />
  </GlobixProvider>,
  document.getElementById('root')
);

Get global state anywhere in your application:

import { useGlobix } from 'globix';

const SomeComponent = () => {
  const { globaslState } = useGlobix();

  return <p>{globalState.name}</p>;
}

Set global state from anywhere you want:

import { useGlobix } from 'globix';

const AnotherComponent = () => {
  const { globalState, setGlobalState } = useGlobix();

  const handleClick = () => {
    setGlobalState({
      ...globalState,
      newValue: 'new value'
    })
  }

  return <button onClick={handleClick}>change name</button>
}

Authors

License

This project is licensed under the MIT License

1.0.13

1 year ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.0

4 years ago