Globix is the easiest way to bring global state to your React App
npm i --save globix
import { GlobixProvider } from 'globix';
ReactDOM.render(
<GlobixProvider initialState={{name: 'Daron Malakian'}}>
<App />
</GlobixProvider>,
document.getElementById('root')
);
import { useGlobix } from 'globix';
const SomeComponent = () => {
const { globaslState } = useGlobix();
return <p>{globalState.name}</p>;
}
import { useGlobix } from 'globix';
const AnotherComponent = () => {
const { globalState, setGlobalState } = useGlobix();
const handleClick = () => {
setGlobalState({
...globalState,
newValue: 'new value'
})
}
return <button onClick={handleClick}>change name</button>
}
- Dinislam Maushov - Initial work - hyposlasher
This project is licensed under the MIT License