1:中文目录bug: 中文目录下 NPM 安装提示成功,VScode可代码提示,实际安装失败。 package.json无相关依赖
2:React Redux MapStateToProps方法不渲染bug:
不渲染,也不报错,原来是React Redux 会检测Reducer中返回的state,注意是检测指针,即使state里面的内容变了,只要reducer返回的还是上一个state的引用,react-redux不会去重新调用MapStateToPros渲染。
3:MapStateToProps触发,render不触发bug。
MapStateToProps都触发了,props都变了,render()方法就是不触发
原因: 这样写改成这样写
bug版本:
const reducer = (state={count:0},action)=> {
console.log('reducer',state)
action.type === 'add' ? state.count = state.count + 1: state.count = state.count
return {...state}
}
export default reducer
无bug版本,不知道啥原因。 只能说坑真TM多
const reducer = (state={count:0},action)=> {
return {
count: state.count + 1
}
}
export default reducer