New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SameValue instead of === to check for dispatchAction equivalence #14752

merged 1 commit into from Feb 4, 2019


None yet
5 participants
Copy link

Jessidhia commented Feb 4, 2019

This allows a Reducer/State that happens to hold a -0 or NaN to not bail out of the bail outs / incorrectly bail out. It's the same algorithm that is used to check the deps array in Effect/Memo/etc.

I'm not sure if this is sufficient test coverage, but it does what I expected (and, more importantly, fails if I undo the changes).


This comment has been minimized.

Copy link

acdlite commented Feb 4, 2019

This makes sense to me, since we also use semantics for PureComponent, memo, context providers, deps, and so on. Thanks for the PR!

@acdlite acdlite merged commit e602b52 into facebook:master Feb 4, 2019

1 check passed

ci/circleci Your tests passed on CircleCI!

@Jessidhia Jessidhia deleted the Jessidhia:use-samevalue-for-dispatchAction branch Feb 5, 2019


This comment has been minimized.

Copy link

thomschke commented Feb 6, 2019

Immutable data structure libraries have their own equality check (like immutable-js).

see -> #14569 (comment)


This comment has been minimized.

Copy link

sudhirj commented Feb 7, 2019

@acdlite @Jessidhia This really needs a giant warning saying "DO NOT USE ARRAYS AS STATE!!!". This completely breaks them:

const [list, setList] = useState([])
setList((l) => {
  return l

is a complete fail, because sees the same array returned, absolutely nothing happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment