Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Adds List validation for reduxComponent #8558

Merged
merged 1 commit into from
Apr 28, 2017
Merged

Conversation

NejcZdovc
Copy link
Contributor

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Resolves #8557

Auditors: @bridiver

Test Plan:

  • create redux component
  • pass prop as a simple List
  • component should not update if props is the same

@NejcZdovc NejcZdovc self-assigned this Apr 28, 2017
@NejcZdovc NejcZdovc requested a review from bridiver April 28, 2017 19:16
@NejcZdovc NejcZdovc changed the title Improves props validation Adds List validation for reduxComponent Apr 28, 2017
@bsclifton bsclifton added this to the 0.15.2 milestone Apr 28, 2017
@NejcZdovc NejcZdovc force-pushed the redux/list branch 2 times, most recently from a315fff to 578004f Compare April 28, 2017 20:10
@NejcZdovc NejcZdovc mentioned this pull request Apr 28, 2017
51 tasks
Copy link
Collaborator

@bridiver bridiver left a 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

@@ -17,6 +17,10 @@ const api = {
return Immutable.List.isList(obj)
},

isSame: (first, second) => {
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -17,6 +17,10 @@ const api = {
return Immutable.List.isList(obj)
},

isSame: (first, second) => {
return second !== null ? first.hashCode() === second.hashCode() : false
Copy link
Collaborator

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

Copy link
Contributor Author

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])
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@NejcZdovc NejcZdovc force-pushed the redux/list branch 3 times, most recently from 2686d23 to 82a7641 Compare April 28, 2017 20:33
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
Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants