摘要: export default function isPlainObject(obj) { /**obj必须为一个对象且不能为null */ if (typeof obj !== 'object' || obj null) return false let proto = obj while (Obj 阅读全文
posted @ 2020-04-12 19:22 前端++ 阅读(174) 评论(0) 推荐(0) 编辑
摘要: applyMiddleware是另一个核心函数 首先我们需要知道如何使用中间件 eg: import { createStore, applyMiddleware } from 'redux' import todos from './reducers' function logger({ getS 阅读全文
posted @ 2020-04-12 19:21 前端++ 阅读(195) 评论(0) 推荐(0) 编辑
摘要: eg:使用代码 //reducers/todos.js export default function todos(state = [], action) { switch (action.type) { case 'ADD_TODO': return state.concat([action.te 阅读全文
posted @ 2020-04-12 19:20 前端++ 阅读(205) 评论(0) 推荐(0) 编辑
摘要: redux源码 redux的源码很简单,分为以下几部分 createStore combineReducers applyMiddleware compose bindActionCreators createStore即入口函数生成store,将reducer和middleware关联起来 com 阅读全文
posted @ 2020-04-12 19:19 前端++ 阅读(384) 评论(0) 推荐(0) 编辑
摘要: 一、redux的思想 redux可能是刚刚接触react时,我遇到比较复杂的问题了。个人认为使用redux并不难,跟着教程敲个计数器什么的也是非常简单的。 redux难就难在理解其思想及原理。经过学习很多文章和查看redux源码后。写下了这个文章,做个记录和总结,以便以后忘记了还能捡起来。 学习re 阅读全文
posted @ 2020-04-12 19:16 前端++ 阅读(336) 评论(0) 推荐(0) 编辑