Skip to content

Commit

Permalink
fix(taro): 在memo中增加对state的浅判断 (#3563)
Browse files Browse the repository at this point in the history
close #3527
  • Loading branch information
onelong authored and yuche committed Jul 1, 2019
1 parent 0418ee2 commit 19eef47
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/taro/src/memo.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 19eef47

Please sign in to comment.