Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zenstack/react-zen-store

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenstack/react-zen-store

React Zen Store is the React binding for [Zen Store](https://github.com/alaboudi/zen-store). It let's your React component retrieve the latest state from the store.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

React Zen Store ☮️

React Zen Store is the React binding for Zen Store. It let's your React component retrieve the latest state from the store.

Installation

yarn add @zenstack/react-zen-store

or

npm install @zenstack/react-zen-store

Usage

This library exposes some hooks that allow you to bind the Zen Store state value to your components.

useState

The useState hook allows your component to stay in sync with the store.

import {createStateStore} from "@zenstack/zen-store";
import {useState} from "@zenstack/react-zen-stack";

const store = createStateStore(13);

const MyComponent = () => {
    const state = useState(store); // assigned 13
    return <p>{state} is my favorite nummber</p>;
}

useSelector

The useSelector hook is similar to useState but it provides the return value of the selector execution on the store.

import {createStateStore} from "@zenstack/zen-store";
import {useSelector} from "@zenstack/react-zen-store";

const store = createStateStore(13);
const selector = (x) => x * 2;

const MyComponent = () => {
    const state = useSelector(store, selector); // assigned 26
    return <p>{state} is double my favorite number</p>
}

Keywords

FAQs

Package last updated on 10 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc