-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try temporarily unobserving and reobserving
- Loading branch information
1 parent
3aeaba7
commit e2d5825
Showing
3 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as React from 'react'; | ||
import TextField from '@mui/material/TextField'; | ||
|
||
export default function App() { | ||
const [value, setValue] = React.useState( | ||
'some long text that makes the input start with multiple rows', | ||
); | ||
|
||
const wrapperRef: React.MutableRefObject<HTMLDivElement | null> = | ||
React.useRef<HTMLDivElement | null>(null); | ||
|
||
React.useEffect(() => { | ||
setTimeout(() => { | ||
if (wrapperRef.current != null) { | ||
wrapperRef.current.style.width = '200px'; | ||
} | ||
}, 5000); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ fontFamily: 'sans-serif', textAlign: 'center' }}> | ||
<div ref={wrapperRef} style={{ width: '100px', transition: 'width 5s ease' }}> | ||
<TextField | ||
multiline | ||
style={{ width: '100%' }} | ||
value={value} | ||
onChange={(ev) => setValue(ev.target.value)} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import TextField from '@mui/material/TextField'; | ||
import { useState, useRef, useEffect } from 'react'; | ||
|
||
export default function App() { | ||
const [value, setValue] = useState( | ||
'some long text that makes the input start with multiple rows', | ||
); | ||
|
||
const wrapper = useRef(); | ||
|
||
useEffect(() => { | ||
setTimeout(() => { | ||
wrapper.current.style.width = '200px'; | ||
}, 2000); | ||
}, []); | ||
|
||
return ( | ||
<div className="App"> | ||
<div className="wrapper" ref={wrapper}> | ||
<TextField | ||
multiline | ||
style={{ width: '100%' }} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters