react-hook-simple-state
v1.0.2
Published
React State Easy
Downloads
4
Maintainers
Readme
Features
- 😎 Easy!!!
- 😎 Support hook
- 😎 Better performance optimization
Install
npm i react-hook-simple-state
# yarn add react-hook-simple-state
# pnpm add react-hook-simple-state
Usage
import { useStore } from "react-hook-simple-state";
// for hook component
function App() {
const [store,setStore] = useStore('countStoreKey',{count:0});
return (
<>
{count}
<button onClick={() => setStore({count: store.count + 1})}>+</button>
<DemoCompoment />
</>
);
}
function DemoCompoment() {
const [store,setStore] = useStore('countStoreKey',{count:0});
return (
<>
{count}
</>
);
}
Basic API
react-hook-simple-state requires the version of React v >= 16.8
| API | Description | |-----------------|--------------------------------------------------------------| | useStore | Create a store container for state |