statezero-react-hooks

0.0.8 • Public • Published

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');
}

/statezero-react-hooks/

    Package Sidebar

    Install

    npm i statezero-react-hooks

    Weekly Downloads

    0

    Version

    0.0.8

    License

    MIT

    Unpacked Size

    7.79 kB

    Total Files

    5

    Last publish

    Collaborators

    • andornaut