1.0.6 • Published 4 years ago

globix-test-version v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

React Global State Hook

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

Installing

npm i --save globix-test-verison

Usage

  1. Wrap your Root Component with GlobixProvider and pass optional initialValues props:
import { GlobixProvider } from 'globix-test-version';

ReactDOM.render(
  <GlobixProvider initialState={{name: 'Daron Malakian'}}>
    <App />
  </GlobixProvider>,
  document.getElementById('root')
);
  1. Get global state anywhere in your application:
import { useGlobix } from 'globix-test-version';

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

  return <p>{globalState.name}</p>;
}
  1. Set global state from anywhere you want:
import {useGlobix} from 'globix-test-version';

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.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago