Skip to content

Commit 5346f1b

Browse files
committed
docs: Update demo
1 parent 1bc6e9a commit 5346f1b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/fill-width.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@ const Demo = () => {
5959
const [responsive, setResponsive] = React.useState(true);
6060
const [inputValue, setInputValue] = React.useState('');
6161
const [inputWidth, setInputWidth] = React.useState(0);
62-
const [data, setData] = React.useState(createData(1));
62+
const [data, setData] = React.useState(createData(3));
63+
const inputRef = React.useRef<HTMLInputElement>();
6364
const measureRef = React.useRef<HTMLDivElement>();
6465

6566
React.useLayoutEffect(() => {
6667
setInputWidth(measureRef.current.offsetWidth);
6768
}, [inputValue]);
6869

70+
React.useEffect(() => {
71+
inputRef.current.focus();
72+
}, []);
73+
6974
return (
7075
<div style={{ padding: 32 }}>
7176
<button
@@ -117,9 +122,10 @@ const Demo = () => {
117122
maxWidth: '100%',
118123
}}
119124
value={inputValue}
120-
onChange={(e) => {
125+
onChange={e => {
121126
setInputValue(e.target.value);
122127
}}
128+
ref={inputRef}
123129
/>
124130
<div
125131
style={{

0 commit comments

Comments
 (0)