From 19eef476e06b42f4aa6617ea64fee95ce70da8fe Mon Sep 17 00:00:00 2001 From: onelong Date: Mon, 1 Jul 2019 10:38:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(taro):=20=E5=9C=A8memo=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9state=E7=9A=84=E6=B5=85=E5=88=A4=E6=96=AD=20(?= =?UTF-8?q?#3563)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #3527 --- packages/taro/src/memo.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/taro/src/memo.js b/packages/taro/src/memo.js index 5f1266b25a8a..90d06ff3e98d 100644 --- a/packages/taro/src/memo.js +++ b/packages/taro/src/memo.js @@ -1,8 +1,11 @@ import { isFunction, objectIs } from './util' export function memo (component, propsAreEqual) { - component.prototype.shouldComponentUpdate = function (nextProps) { - return isFunction(propsAreEqual) ? !propsAreEqual(this.props, nextProps) : !objectIs(this.props, nextProps) + component.prototype.shouldComponentUpdate = function (nextProps, nextState) { + return ( + (isFunction(propsAreEqual) ? !propsAreEqual(this.props, nextProps) : !objectIs(this.props, nextProps)) && + !objectIs(this.state, nextState) + ) } return component