I do not understand how to pass data to the list
See original GitHub issueI read the docs and saw the examples. All of them seem to pass to the list a component rather than a JSX. So how do I pass data to the rows? I tried adding a data tag to the List but to no avail.
import React, { useRef, useEffect } from "react";
import { VariableSizeList as List } from "react-window";
// These row heights are arbitrary.
// Yours should be based on the content of the row.
const rowHeights = new Array(1000)
.fill(true)
.map(() => 25 + Math.round(Math.random() * 50));
const getItemSize = index => rowHeights[index];
function Row(props) {
console.log("props -> ", props);
const { index, style } = props;
return <div style={style}>Row {index}</div>;
}
const data = [
{ id: 1, name: "james" },
{ id: 2, name: "james" },
{ id: 3, name: "james" },
{ id: 4, name: "james" },
{ id: 5, name: "james" },
];
function VirtualList(props) {
const listRef = useRef();
useEffect(() => {
listRef.current.scrollToItem(200, "start");
}, []);
return (
<List
ref={listRef}
height={150}
data={data}
itemCount={1000}
itemSize={getItemSize}
width={300}
>
{Row}
</List>
);
}
export default VirtualList;
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
c# - How to pass data to list? - Stack Overflow
First add class Client in separated .cs file. public class Client { public string Telefon { get; set; } public string Navn {...
Read more >Function arguments - Manual - PHP
Information may be passed to functions via the argument list, which is a comma-delimited list of expressions. The arguments are evaluated from left...
Read more >Pass-by-value, reference, and assignment | Pydon't - Mathspp
This article explains why Python doesn't use a pass-by-value system, nor a pass-by-reference.
Read more >More on data validation - Microsoft Support
You can use data validation to restrict the type of data or values that users enter into cells. This is an advanced topic...
Read more >Defining Your Own Python Function
You'll also learn about passing data to your function, and returning data ... the sentinel value indicates no argument is given, create a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Use the itemData prop
https://react-window.now.sh/#/examples/list/memoized-list-items
On Tue, Nov 5, 2019 at 4:18 AM guywek notifications@github.com wrote:
the docs still confusing.