-
Notifications
You must be signed in to change notification settings - Fork 973
Adds List validation for reduxComponent #8558
Conversation
a315fff
to
578004f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ with some minor changes
app/common/state/immutableUtil.js
Outdated
@@ -17,6 +17,10 @@ const api = { | |||
return Immutable.List.isList(obj) | |||
}, | |||
|
|||
isSame: (first, second) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to avoid confusion I think should probably is isSameHashCode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/common/state/immutableUtil.js
Outdated
@@ -17,6 +17,10 @@ const api = { | |||
return Immutable.List.isList(obj) | |||
}, | |||
|
|||
isSame: (first, second) => { | |||
return second !== null ? first.hashCode() === second.hashCode() : false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if both objects are null it should return true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return Object.keys(nextState).some((prop) => nextState[prop] !== this.state[prop]) || | ||
Object.keys(nextProps).some((prop) => nextProps[prop] !== this.props[prop]) | ||
return Object.keys(nextState).some((prop) => { | ||
return isList(nextState[prop]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a little more complicated now it would probably be better to pass an instance method to both instead of using anonymous functions. It would be slightly faster anyway and avoid the overhead of creating and GCing the closure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
2686d23
to
82a7641
Compare
Resolves brave#8557 Auditors: @bridiver Test Plan: - create redux component - pass prop as a simple List - component should not update if props is the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
git rebase -i
to squash commits (if needed).Resolves #8557
Auditors: @bridiver
Test Plan: