-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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] Too many re-renders
error when component is mounted with a value which almost but not quite wraps to a new line
#40557
Comments
Hello @Halvi3 Can you guide me i am unable to get error messages in the console with your description so please guide me |
I am unable to see error messages by following your description so kindly guide me so that i can resolve the issue |
Fine , Thank You |
Is this connected to #33081 or #20106? Does this solution resolve the issue? |
It clearly seems related to those previous issues which were marked as fixed, I presume there were multiple other situations where the same error occurred that might have been fixed in the past, but I was able to narrow down this more specific edge case as one which could consistently reproduce the error even in the most up to date version of MUI (and the edge case that our application was specifically encountering) The stackoverflow answer you linked does not really resolve the issue, disabling the autosize functionality because its broken doesn't make it... not broken? And in my particular use case for these components, we need the TextField to expand or contract dynamically to however many rows it takes to display the text value, we can't set a fixed number of rows which might leave empty space for short values but overflow with longer values, and disabling multiline entirely is a non-starter |
@ZeeshanTamboli I saw you pushed an update in #40789 but im still seeing the issue, was there a change on the user side that needed to be made? |
@c-mella Which Material UI version are you using? |
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/multilinetextfields-demo-material-ui-forked-thqdzq
Steps:
Current behavior
When mounted and rendered for the first time in React 18 StrictMode, if the value in a multiline TextField or other multiline input component almost wraps to a new line, the TextareaAutosize handlers will cause an infinite loop and spam the console with 'too many renders' error messages. When the loop is terminated and the layout stabilizes, the TextField will be one line too tall for what the text value actually 'needs' to fit.
At this point, if the autosize calculations are run again for whatever reason (like changing the text value at all, or resizing the screen) the next iteration will complete instantly and correctly and the TextField will snap to the right size, removing the empty line and no longer generating errors
Expected behavior
multiline TextFields or other components using TextareaAutosize should be able to fit to a stable height of their initial text content when first mounted without generating errors, and the height they start at should be correct for the initial text content, even if that text content is close to but not quite wrapping to another line
Context
Our application renders a large editable form representing the profile data of an entity in a knowledge management system. Many of the fields in this form display security data which by policy cannot be truncated and must be shown in their entirety, so workarounds for this issue like setting a maximum or fixed number of rows are not possible, since the users needs to be able to see the full value regardless of it is fit on one line or multiple, without scrolling
When developing locally, hitting 'edit' to bring up this form mounts a large number of fields which generate this error all at once (depending on the data currently populating them), filling the console with the errors in abundance, causing significant performance issues and also making the console impossible to use when trying to diagnose separate issues.
Your environment
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: