-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Closed
Labels
component: TextareaAutosizeThe React component.The React component.good first issueGreat for first contributions. Enable to learn the contribution process.Great for first contributions. Enable to learn the contribution process.type: bugIt doesn't behave as expected.It doesn't behave as expected.
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
When React 18.0.0 triggers a Suspense that hides a mounted <Input multiline />, TextareaAutosize @ syncHeight throws the following uncaught exception:
TextareaAutosize.js:42 Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
at eval (TextareaAutosize.js:42:43)
at ResizeObserver.eval (TextareaAutosize.js:87:7)
at later (debounce.js:9:12)
It seems like the exception can be ignored, but react dev server shows the uncaught exception window.
Expected behavior 🤔
<Input multiline /> should not throw exceptions when it enters suspense.
Steps to reproduce 🕹
Steps:
- Open sandbox https://codesandbox.io/s/eager-hertz-6g658v?file=/src/app.js
- Click on "Toggle View" button
- // The app momentarily enters suspense loading the lazy route
- // The exception is shown
For future reference, sandbox code:
import { Input, Button } from '@mui/material';
import { Suspense, useState, lazy } from 'react';
const LazyRoute = lazy(async () => {
// Force react to show fallback suspense
await new Promise(resolve => setTimeout(resolve, 1000));
return import('./lazyRoute');
});
export function App() {
const [showRoute, setShowRoute] = useState(false);
return <Suspense fallback={null}>
<Button onClick={() => setShowRoute(r => !r)}>Toggle view</Button>
<hr />
{ showRoute ? <LazyRoute /> : <Input multiline inputProps={{ minRows: 4 }} defaultValue="Text" /> }
</Suspense>
}Context 🔦
When upgrading existing application to react 18, after changing from one route that has an <Input multiline> to another one
Your environment 🌎
No response
danielabbasi, armantc, hafidk, ac2-warp, marcusjwhelan and 7 more
Metadata
Metadata
Assignees
Labels
component: TextareaAutosizeThe React component.The React component.good first issueGreat for first contributions. Enable to learn the contribution process.Great for first contributions. Enable to learn the contribution process.type: bugIt doesn't behave as expected.It doesn't behave as expected.