From 856fb63e25f7e539febe0af833d6b3f32ea46316 Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Mon, 27 May 2019 16:04:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(taro-redux):=20props=20=E5=AF=B9=E6=AF=94?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=85=A8=E7=AD=89=EF=BC=8Cclose=20#3165?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit props 改造前小程序端 props 会被序列化,所以需要手写对比。但改造后引用是指向同一处的,可以改回为全等判断。 --- packages/taro-redux/src/connect/connect.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/taro-redux/src/connect/connect.js b/packages/taro-redux/src/connect/connect.js index ce348ce9d91c..ea12fcc3b61a 100644 --- a/packages/taro-redux/src/connect/connect.js +++ b/packages/taro-redux/src/connect/connect.js @@ -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) @@ -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 }