Nurturing Palpable Magnificence
    Wondering what’s next for npm?Check out our public roadmap! »

    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.

    Install

    npm i use-simple-shared-state

    DownloadsWeekly Downloads

    5

    Version

    0.0.2

    License

    ISC

    Unpacked Size

    2.87 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar