statezero-react-hooks
v0.0.8
Published
React hooks for Statezero
Downloads
6
Maintainers
Readme
statezero-react-hooks
React hooks for statezero.
Getting Started
Install from npm.
# Install peer dependencies
npm install react --save
npm install statezero --save
npm install statezero-react-hooks --save
ES6 Module
import { useStatezero } from 'statezero-react-hooks';
ES6 Module with tree shaking (not transpiled)
// Note that the import path ends with '/src'
import { useStatezero } from 'statezero-react-hooks/src';
Usage
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);
Example React components
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');
}