React hooks for statezero.
Install from npm.
# Install peer dependencies
npm install react --save
npm install statezero --save
npm install statezero-react-hooks --save
import { useStatezero } from 'statezero-react-hooks';
// Note that the import path ends with '/src'
import { useStatezero } from 'statezero-react-hooks/src';
Provides the following functions:
import { useStatezero, useStatezeroPath, useStatezeroPathSync, useStatezeroSync } from 'statezero-react-hooks';
let state, setState;
state = useStatezero(selector);
state = useStatezeroSync(selector);
[state, setState] = useStatezeroPath(path);
[state, setState] = useStatezeroPathSync(path);
import { useStatezero, useStatezeroPath } from 'statezero-react-hooks/src';
export const component = ({ selector }) => {
const state = useStatezero(selector);
// ...
}
export const component = () => {
const [z, setZ] = useStatezeroPath('x.y.z');
}