Skip to content
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

Fix rerenders in with-context-api example #8559

Merged
merged 1 commit into from
Aug 29, 2019

Conversation

HaNdTriX
Copy link
Contributor

The code before this PR had several issues:

  1. Context uses reference identity to determine when to re-render, there are some gotchas that could trigger unintentional renders in consumers when a provider’s parent re-renders. https://reactjs.org/docs/context.html#caveats

  2. setState should use the reducer pattern in this example to make sure clicks are not swallowed by react batch.

## Motivation

The code before this PR had serveral issues:

1. Context uses reference identity to determine when to re-render, there are some gotchas that could trigger unintentional renders in consumers when a provider’s parent re-renders.

https://reactjs.org/docs/context.html#caveats

2. `setState` should use the reducer pattern in this example to make sure clicks are not swallowed by react batch.
@HaNdTriX HaNdTriX changed the title Fix with-context-api example Fix rerenders in with-context-api example Aug 29, 2019
@Timer Timer added ready to land examples Issue/PR related to examples labels Aug 29, 2019
@Timer Timer added this to the 9.0.6 milestone Aug 29, 2019
@Timer Timer merged commit aa406a1 into vercel:canary Aug 29, 2019
@HaNdTriX HaNdTriX deleted the examples/with-context-api branch August 29, 2019 22:45
@vercel vercel locked as resolved and limited conversation to collaborators Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants