use-simple-shared-state

0.0.2 • Public • Published

SimpleSharedState React Hook

Redux is verbose. SimpleSharedState is brief.

Get It

npm install use-simple-shared-state

Basic Use

Assuming you already have a store made with simple-shared-state:

import React from "react";
import useSharedState from "use-simple-shared-state";
import store from "./store.js";
 
const selectors = [
    (state) => state.counter1,
    (state) => state.examples.user,
    // put as many selectors here as you need
];
 
export const MyComponent = () => {
    const [count1, someObject] = useSharedState(store, selectors);
    return (
        <div>
            <h1>Hello World</h1>
            <span>{count1}</span>
            <pre>{JSON.stringify(someObject)}</pre>
        </div>
    )
};

That's all there is to it.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.22latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.22
0.0.10

Package Sidebar

Install

npm i use-simple-shared-state

Weekly Downloads

2

Version

0.0.2

License

ISC

Unpacked Size

2.87 kB

Total Files

4

Last publish

Collaborators

  • rm-rf-etc