Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs React虚拟化InfiniteLoader不渲染任何内容_Reactjs_Infinite Scroll_React Virtualized - Fatal编程技术网

Reactjs React虚拟化InfiniteLoader不渲染任何内容

Reactjs React虚拟化InfiniteLoader不渲染任何内容,reactjs,infinite-scroll,react-virtualized,Reactjs,Infinite Scroll,React Virtualized,正如标题所示,InfiniteLoader不会渲染任何项目。我似乎已经把所有的东西都设置好了,集合中有很多东西要呈现,但是页面上什么都没有显示。以下是渲染方法: render() { const rows = this.state.rows const rowsCount = this.state.hasNextPage ? rows.length + 1 : rows.length // Only load 1 page of items at a time.

正如标题所示,InfiniteLoader不会渲染任何项目。我似乎已经把所有的东西都设置好了,集合中有很多东西要呈现,但是页面上什么都没有显示。以下是渲染方法:

render() {
    const rows = this.state.rows
    const rowsCount = this.state.hasNextPage ? rows.length + 1 : rows.length

    // Only load 1 page of items at a time.
    // Pass an empty callback to InfiniteLoader in case it asks us to load more than once.
    const loadMoreRows = this.state.nextPageLoading ? () => {} : this.loadNextPage

    // Every row is loaded except for our loading indicator row.
    const isRowLoaded = ({ index }) => !this.state.hasNextPage || index < rows.length

    // Render a list item or a loading indicator.
    const rowRenderer = ({ index, key, style }) => {
      if (!isRowLoaded({ index })) {
        console.log("LOADING") // NEVER GETS CALLED
        return(
          <div style={style}>
            Loading...
          </div>
        )
      } else {
        console.log(rows[index]) // NEVER GETS CALLED
        return(
          <MyRow key={index}
            row={rows[index]} />
        )
      }
    }

    console.log(rows) // SHOWS AN ARRAY WITH PLENTY OF ROWS
    return(
      <InfiniteLoader
        isRowLoaded={isRowLoaded}
        loadMoreRows={loadMoreRows}
        rowCount={rowsCount}>
        {({ onRowsRendered, registerChild }) => (
          <AutoSizer>
            {({ height, width }) => (
              <List
                height={height}
                width={width}
                ref={registerChild}
                onRowsRendered={onRowsRendered}
                rowCount={this.state.totalCount}
                rowHeight={46}
                rowRenderer={rowRenderer}
              />
            )}
          </AutoSizer>
        )}
      </InfiniteLoader>
    );
  }
render(){
const rows=this.state.rows
const rowscont=this.state.hasNextPage?rows.length+1:rows.length
//一次只能加载1页的项目。
//将空回调传递给InfiniteLoader,以防它要求我们多次加载。
const loadMoreRows=this.state.nextPageLoading?()=>{}:this.loadNextPage
//每一行都被加载,除了我们的加载指示符行。
const isRowloated=({index})=>!this.state.hasNextPage | | index{
如果(!isRowloated({index})){
console.log(“加载”)//永远不会被调用
返回(
加载。。。
)
}否则{
console.log(rows[index])//永远不会被调用
返回(
)
}
}
console.log(rows)//显示包含大量行的数组
返回(
{({onRowsRendered,registerChild})=>(
{({高度,宽度})=>(
)}
)}
);
}

这是一个问题,AutoSizer的高度为0。通过将AutoSizer封装在具有设定高度的div中解决。

您能否提供一个Plnkr来重新编程problem@brianvaughn我看看我能做什么@布莱恩·沃恩,谢谢!如果你还记得的话,我可以问你是怎么知道的吗。这似乎是一个随机的错误