Gathering detailed insights and metrics for react-state-pool
Gathering detailed insights and metrics for react-state-pool
Gathering detailed insights and metrics for react-state-pool
Gathering detailed insights and metrics for react-state-pool
npm install react-state-pool
Typescript
Module System
Node Version
NPM Version
65.2
Supply Chain
88.6
Quality
75.4
Maintenance
100
Vulnerability
100
License
TypeScript (96.17%)
JavaScript (3.83%)
Total Downloads
1,279
Last Day
1
Last Week
31
Last Month
61
Last Year
295
1 Stars
17 Commits
1 Watching
2 Branches
2 Contributors
Latest Version
0.0.9
Package Id
react-state-pool@0.0.9
Unpacked Size
30.39 kB
Size
8.78 kB
File Count
78
NPM Version
8.19.1
Node Version
18.9.0
Publised On
22 Feb 2023
Cumulative downloads
Total Downloads
Last day
-88.9%
1
Compared to previous day
Last week
244.4%
31
Compared to previous week
Last month
577.8%
61
Compared to previous month
Last year
-70%
295
Compared to previous year
2
24
This is a simple library to manage state in react applications.
To avoid messing up state management, it aims to tackle only one issue is making global data become global state with a minimum number of APIs. All APIs are very easy to start with.
1yarn add react-state-pool
Or
1npm install react-state-pool
It requires two steps to use this library
initStatePool
usePoolState
hook to use data stored in state pool as global state inside component1import {initStatePool} from 'react-state-pool'; 2 3const inititalData = {count: null}; 4const myPool = initStatePool(initialdata); 5 6// Use disabled argument to subcribe and unsubcribe to state update dynamically 7function Playground(props) { 8 const [count, setCount] = usePoolState({ 9 pool, 10 fieldName: 'count', 11 disabled: props?.disabled, 12 }); 13 14 return ( 15 <div> 16 <p>{count}</p> 17 <button onClick={() => setCount(prv => prv + 1)}>Increase Count</button> 18 </div> 19 ); 20} 21 22// Use setValue method to update state outside component 23export async function getData() { 24 const res = await fetch('url'); 25 res?.data?.count && pool.setValue('count', res.data.count); 26}
No vulnerabilities found.
No security vulnerabilities found.