export function createStore(reducer){ let currentState={} let currentListeners=[] function getState(){ return currentState } function subscribe(listener){ currentListeners.push(listener) } function dispatch(action){ debugger currentState=reducer(curr
简介: 手写实现redux基础api createStore( )和store相关方法 api回顾: createStore(reducer, [preloadedState], enhancer) 创建一个 Redux store 来以存放应用中所有的 state reducer (Function): 接收两个参数,当前的 state 树/要处理的 action,返回新的 state 树 preloadedState: 初始时的 state enhancer (Function): stor
In this lesson, I refactor a simple Counter component connected to Redux to use Unstated instead. I explain some of the cognitive overhead of working with Redux and how Unstated can help simplify your application codebase. Additional Resources https: