Skip to content

Commit

Permalink
feat(taro-redux): props 对比改为全等,close #3165
Browse files Browse the repository at this point in the history
props 改造前小程序端 props 会被序列化,所以需要手写对比。但改造后引用是指向同一处的,可以改回为全等判断。
  • Loading branch information
Chen-jj committed May 27, 2019
1 parent 6e1703d commit 856fb63
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions packages/taro-redux/src/connect/connect.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import { shallowEqual } from '@tarojs/utils'

import { getStore } from '../utils/store'
import { mergeObjects, isObject } from '../utils'

function isEqual (a, b) {
const typeA = typeof a
const typeB = typeof b
if (typeA !== typeB) {
return false
}
if (typeA === 'object') {
return shallowEqual(a, b)
}
return a === b
}

function wrapPropsWithDispatch (mapDispatchToProps, dispatch) {
if (typeof mapDispatchToProps === 'function') {
return mapDispatchToProps(dispatch)
Expand Down Expand Up @@ -49,7 +35,7 @@ export default function connect (mapStateToProps, mapDispatchToProps) {
if (isObject(val) && isObject(initMapDispatch[key])) {
val = mergeObjects(val, initMapDispatch[key])
}
if (!isEqual(this.props[key], val)) {
if (this.props[key] !== val) {
this.props[key] = val
isChanged = true
}
Expand Down

0 comments on commit 856fb63

Please sign in to comment.