1.0.14 • Published 3 years ago
react-gstatem v1.0.14
GStatem is a small, simple and fast state-management tool.
Installation
npm
npm i react-gstatem
yarn
yarn add react-gstatem
Demos
Basic usage of function component
Create a store
The increaseCount
function can be used anywhere - in component, utils file, event listener, setTimeout, setInterval and promise callbacks.
// Store.js
import { create } from "react-gstatem";
const { useSelect, dispatch } = create({
/* initial state */
state: { count: 0 }
});
/* the count hook for function component */
export const useCount = () => useSelect(state => state.count);
/* increase the counter */
export const increaseCount = () => dispatch(state => ({ count: state.count + 1 }));
Use the store in component
import React from "react";
import Counter from "./Counter";
import { useCount, increaseCount } from "./Store";
const BasicUsage = () => {
const count = useCount();
return (
<Counter value={count} onIncrement={increaseCount} />
);
};
export default BasicUsage;
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.11
3 years ago
1.0.10
3 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.12
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
1.0.0-alpha.15
3 years ago
1.0.0-alpha.14
3 years ago
1.0.0-alpha.13
3 years ago
1.0.0-alpha.12
3 years ago
1.0.0-alpha.9
3 years ago
1.0.0-alpha.8
3 years ago
1.0.0-alpha.7
3 years ago
1.0.0-alpha.6
3 years ago
1.0.0-alpha.5
3 years ago
1.0.0-alpha.4
3 years ago
1.0.0-alpha.3
3 years ago
1.0.0-alpha.2
3 years ago