()
| 7 | } from "react-window"; |
| 8 | |
| 9 | export function ListDynamicRoute() { |
| 10 | const params = new URLSearchParams(location.search); |
| 11 | const listRef = useListRef(null); |
| 12 | const [rowCount, setRowCount] = useState(500); |
| 13 | const rowHeight = useDynamicRowHeight({ |
| 14 | defaultRowHeight: Number(params.get("estimate") ?? 25) |
| 15 | }); |
| 16 | return ( |
| 17 | <> |
| 18 | <button |
| 19 | onClick={() => |
| 20 | listRef.current?.scrollToRow({ |
| 21 | index: Number(params.get("index") ?? 250), |
| 22 | align: (params.get("align") ?? "auto") as |
| 23 | | "auto" |
| 24 | | "start" |
| 25 | | "center" |
| 26 | | "end" |
| 27 | | "smart", |
| 28 | behavior: "smooth" |
| 29 | }) |
| 30 | } |
| 31 | > |
| 32 | Jump |
| 33 | </button> |
| 34 | <button |
| 35 | onClick={() => |
| 36 | listRef.current?.scrollToRow({ index: 20, align: "start" }) |
| 37 | } |
| 38 | > |
| 39 | Replace |
| 40 | </button> |
| 41 | <button onClick={() => setRowCount(10)}>Shrink</button> |
| 42 | <List |
| 43 | children={ |
| 44 | params.has("overlay") ? ( |
| 45 | <div |
| 46 | data-testid="overlay" |
| 47 | style={{ position: "absolute", height: 10 }} |
| 48 | > |
| 49 | Overlay |
| 50 | </div> |
| 51 | ) : undefined |
| 52 | } |
| 53 | listRef={listRef} |
| 54 | style={{ height: 200, width: 300 }} |
| 55 | rowCount={rowCount} |
| 56 | rowHeight={rowHeight} |
| 57 | rowComponent={Row} |
| 58 | rowProps={{ tall: params.has("tall") }} |
| 59 | /> |
| 60 | </> |
| 61 | ); |
| 62 | } |
| 63 | |
| 64 | function Row({ |
| 65 | index, |
nothing calls this directly
no test coverage detected