import React from 'react'; import { createStore } from 'react-hooks-global-state'; const reducer = (state, action) => { switch (action.type) { case 'increment': return { ...state, count: state.count + 1 }; case 'decrement': return { ...state, count: state.count - 1 }; ...
npm install react-hooks-global-state Usage setState style importReactfrom'react';import{createGlobalState}from'react-hooks-global-state';constinitialState={count:0};const{useGlobalState}=createGlobalState(initialState);constCounter=()=>{const[count,setCount]=useGlobalState('count');return(Counter:...
I really like how almost identical it is to redux, and how it enables me early access to some of the things that might trickle down into react-redux. I don't like however that initial state is required. I use typesafe-actions for mostly everything. And I use initial state in my reduc...
Rekv 是一个为 React 函数式组件设计的全局状态管理器,且对类组件具有很好的兼容,所有方法与状态均有 TypeScript 提示 English Document 特色 一个简单但易用的状态管理器 无Redux,无依赖,gzip 后仅有 1.5 KB 不使用高阶组件(HOC) 支持Hooks 与类组件 ...