Skip to content

Conversation

@exuanbo
Copy link

@exuanbo exuanbo commented Sep 7, 2024

Similar to facebook/react#25968

The reducer is used for memoization, not managing state. So I think it's ok to mutate the tuple, since the reducer is already not a pure function.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 7, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@dai-shi
Copy link
Member

dai-shi commented Sep 7, 2024

Isn't it just a little optimization to avoid calling the selector in an edge case.

If it can cause a bug, can you create a test case please?

Hm, looking at facebook/react#25968, it's a bit different from ours. We don't have a memoized value, and useReducer works without memoizing the selector.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants