gstatem-devtools
The DevTools helpers for gstatem and react-gstatem.
Installation
npm
npm i gstatem-devtools
yarn
yarn add gstatem-tools
Demos
Usage
The increaseCount function can be used anywhere - in component, utils file, event listener, setTimeout, setInterval and promise callbacks.
Create a store with Devtools
// Store.js
import { create } from "react-gstatem";
import DevTools from "gstatem-devtools";
const { useSelect, dispatch } = create(
new DevTools({
/* 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 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;
Every dispatched piece will be logged in the Chrome extension GStatem-DevTools if the devtools is installed.
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 1.0.14 | MIT | |
| 1.0.13 | MIT | |
| 1.0.12 | MIT | |
| 1.0.11 | MIT | |
| 1.0.10 | MIT | |
| 1.0.9 | MIT | |
| 1.0.8 | MIT | |
| 1.0.7 | MIT | |
| 1.0.6 | MIT | |
| 1.0.5 | MIT | |
| 1.0.4 | MIT | |
| 1.0.3 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT |
Pre-releases (10)
| Version | Released | License |
|---|---|---|
| 1.0.0-alpha.14 | MIT | |
| 1.0.0-alpha.13 | MIT | |
| 1.0.0-alpha.12 | MIT | |
| 1.0.0-alpha.11 | MIT | |
| 1.0.0-alpha.8 | ||
| 1.0.0-alpha.7 | ||
| 1.0.0-alpha.6 | ||
| 1.0.0-alpha.5 | ||
| 1.0.0-alpha.4 | ||
| 1.0.0-alpha.2 |