-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[TextareaAutosize] prevent redundant state updates #32783
Conversation
@oliviertassinari To reproduce the infinite loop, |
I personally don't understand how the changes make things different from the current state of things (we already have a piece of logic to prune rerenders), nor what problem we are trying to solve, please expand on both. By "needs test" the minimum required is a way to reproduce the bug. Note that we never merge PRs to fix a bug we didn't reproduce. Also note that our tests infrastructure support browser tests, both running end-to-end and in the browser runtime (preferred). |
As I mentioned in the PR description, the bug is reproducible. #20106 (comment) |
This comment was marked as resolved.
This comment was marked as resolved.
Found this bug in the wild and it led me here. This can be easily repro'd on official MUI documentation for the "controlled" multiline textarea when you open in codesandbox. Repro
I would really appreciate a fix getting merged. Thanks. |
@aeharding Great thanks, so it seems to be React 18.1.0 specific. It works correctly on React 17.0.2, proof: #20106 (comment). To figure out what's the root problem. The current diff in the PR makes me think that we are not solving the root problem. Meaning that as soon as we hit a case where the layout is slightly unstable, we would face the same infinite rendering/height out-of-sync problem (the warning only being the tip of the iceberg). |
I still don't know why I get this error in React v18, but it may be a problem with syncHeight() using useEnhancedEffect (useLayoutEffect?) in the following
↓
This message is written using the translation function. |
fixes: #20106
Fixed an infinite loop caused by the interaction of
useEnhancedEffect(useLayoutEffect)
anduseState
by skipping unnecessary state updates.I have confirmed that this patch works in the following reproduction codes.
#20106 (comment)
NOTE: Applying this change may make it unnecessary to limit the number of renderings in the future 😎
#19743