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

back-store

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

back-store

Minimalist state management tools only for React.js

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

useStore

Minimalist state management tools only for React.js

Features

  • Progressive adoption
  • Minimalist api
  • Extremely reusable
import React from 'react';
import Store, { useStore } from 'back-store';
const Root = () => {
  return (
    <Store value={{ page1: { count: 1 }, page2: { a: { b: 'hello' } } }}>
      <App />
    </Store>
  );
};

const App = () => {
  const [store, setStore] = useStore('page1'); // getting Store state from store
  const { count } = store;
  const plusOne = () => setStore({ count: count + 1 }); // just like setState
  const plusTen = () => setStore(store => ({ count: count + 10 })); // support function
  const minusOne = () => setStore('count', count - 1); // lodash.set like syntax for possible deep structure setStore('a.b.c', xx)
  return (
    <div>
      <div>{count}</div>
      <button onClick={plusOne}>+</button>
      <button onClick={plusOne}>+10</button>
      <button onClick={minusOne}>-</button>
    </div>
  );
};

export default Root;

CHANGELOG

v1.1.0

添加函数式调用

FAQs

Package last updated on 04 Nov 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