2.0.5 • Published 2 years ago

@alevnyacow/shared-react-variables v2.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Shared React variables

npm GitHub GitHub last commit npm GitHub top language code style: prettier

About

Shared React variables provide you easy and comfortable global state management based on hooks. You can treat it like a global mutable useState. Isn't it awesome?

🔍 Example

import { createUseSharedVariable } from "@alevnyacow/shared-react-variables"; 

const [useTimer] = createUseSharedVariable({ ticks: 0 });

const Timer = () => {
    const timer = useTimer();
    useEffect(() => {
        setInterval(() => {
            timer.ticks++;
        }, 1000);
    }, []);

    return <div>{timer.ticks}</div>
};

const AnotherTimerWithSameState = () => {
    // using pretty same timer in another place
    const timer = useTimer();

    return <div>{timer.ticks}</div>
};

💡 Codesandbox

https://codesandbox.io/s/react-shared-variables-example-f7feo7

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago