Skip to content

Commit

Permalink
fix(redux): 特殊情况下redux更新无法触发视图更新, fix #8705 (#8709)
Browse files Browse the repository at this point in the history
* fix(redux): 特殊情况下redux更新无法触发视图更新, fix #8705

* fix: 语法错误
  • Loading branch information
myl0204 authored Feb 22, 2021
1 parent 62ae4b0 commit 4e89ff2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/taro-redux/src/connect/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ export default function connect (mapStateToProps, mapDispatchToProps) {
let isChanged = false
const newMapState = mapStateToProps(store.getState(), this.props)
const prevProps = Object.assign({}, this.props)
const props = Object.assign({}, this.props)
Object.keys(newMapState).forEach(key => {
let val = newMapState[key]
if (isObject(val) && isObject(initMapDispatch[key])) {
val = mergeObjects(val, initMapDispatch[key])
}
if (this.props[key] !== val) {
this.props[key] = val
if (props[key] !== val) {
props[key] = val
isChanged = true
}
})
if (isChanged) {
if (!this._dirty) {
this.prevProps = prevProps
}
this.props = props
this._unsafeCallUpdate = true
this.setState({}, () => {
delete this._unsafeCallUpdate
Expand Down

0 comments on commit 4e89ff2

Please sign in to comment.