forked from petyosi/react-virtuoso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresizing-items.tsx
42 lines (37 loc) · 846 Bytes
/
resizing-items.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as React from 'react'
import { useState, useEffect } from 'react'
import { Virtuoso } from '../src/'
const Item = (props: { index: number }) => {
const [loaded, setLoaded] = useState(false)
useEffect(() => {
const to = setTimeout(() => {
setLoaded(true)
}, 200)
return () => {
clearTimeout(to)
}
}, [])
return (
<div
style={{
outline: `1px solid green`,
height: loaded ? 50 : 100,
}}
>
{loaded ? `Item ${props.index}` : `Loading...`}
</div>
)
}
export default function App() {
return (
<div className="App" style={{ height: 300, outline: `1px solid red` }}>
<Virtuoso
style={{ height: 300 }}
itemContent={(index) => {
return <Item index={index} />
}}
totalCount={100}
/>
</div>
)
}