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

Bug: Unnecessary re-render #18719

Closed
behnammodi opened this issue Apr 23, 2020 · 7 comments
Closed

Bug: Unnecessary re-render #18719

behnammodi opened this issue Apr 23, 2020 · 7 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@behnammodi
Copy link
Contributor

y

React version: 16.13.1

Steps To Reproduce

1- The first render is correct
2- The second re-render is correct because X changes from 1 to 2
3- The third re-render in the wrong

Link to code example:
https://codesandbox.io/s/bug-in-render-ldycb

The current behavior

The third re-render is unnecessary but happen

The expected behavior

The third re-render should not happen

@behnammodi behnammodi added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Apr 23, 2020
@eps1lon
Copy link
Collaborator

eps1lon commented Apr 23, 2020

Does this happen with the production build as well? I'm asking because it doesn't actually commit when transitioning from 2->2.

You can observe this wrapping the (side-effect) in useEffect:

React.useEffect(() => {
  console.log("render App", x);
})

@eps1lon
Copy link
Collaborator

eps1lon commented Apr 23, 2020

Also: Probably a duplicate of #14994

@behnammodi
Copy link
Contributor Author

@eps1lon Yes It's happen

@eps1lon
Copy link
Collaborator

eps1lon commented Apr 23, 2020

Fairly certain this is a duplicate of #14994. Child won't re-render on the 2->2 transition: https://codesandbox.io/s/bug-in-render-ubppr?file=/src/index.js. There's some explanation in that thread for the current behavior.

@behnammodi
Copy link
Contributor Author

behnammodi commented Apr 23, 2020

@eps1lon Thanks, but every solution is awful.

@eps1lon
Copy link
Collaborator

eps1lon commented Apr 23, 2020

@eps1lon Thanks, but every solution is awful.

I can understand why this might be undesired behavior for you. But this won't get solved by keeping duplicate issues open which require maintenance from the core team.

It also helps keeping the discussion focused so that potential workarounds aren't spread over the repository.

@behnammodi
Copy link
Contributor Author

@eps1lon All right, I'll close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

2 participants