【问题标题】:Why isn't onSectionRendered being called on my List?为什么我的列表中没有调用 onSectionRendered?
【发布时间】:2017-08-06 17:30:35
【问题描述】:

由于某种原因,我的列表中没有调用 onSectionRendered。其他一切工作正常。不确定我是否正确传递了它。当我最初加载网格列表或不同的行变得可见时,它不会呈现。

<AutoSizer>
    {({ width, height }) =>
    <List
        ref={this.set_reference}
        className={stylesheet.nestedVirtualizedList}
        width={width}
        height={height}
        onSectionRendered={()=>{console.log('Please show up ;(')}}
        onScroll={this.update_scroller_position}
        rowCount={this.props.data.length}
        rowHeight={(this.props.get_dynamic_height) ? this.props.get_dynamic_height : height}
        rowRenderer={this.render_row}
        overscanRowCount={this.props.overscan_row_count}

        />
    }
</AutoSizer>

我也试过这个...

<AutoSizer>
      {({ width, height }) =>
      <List
          {...{onSectionRendered:this.on_section_rendered}}
          ref={this.set_reference}
          className={stylesheet.nestedVirtualizedList}
          width={width}
          height={height}
          onScroll={this.update_scroller_position}
          rowCount={this.props.data.length}
          rowHeight={(this.props.get_dynamic_height) ? this.props.get_dynamic_height : height}
          rowRenderer={this.render_row}
          overscanRowCount={this.props.overscan_row_count}

          />
      }
  </AutoSizer>

【问题讨论】:

    标签: javascript react-virtualized


    【解决方案1】:

    List 属性被命名为onRowsRendered(检查docs):

    onRowsRendered

    使用刚刚呈现的行切片的信息调用回调:({ overscanStartIndex: number, overscanStopIndex: number, startIndex: number, stopIndex: number }): void

    【讨论】:

    • 好吧,我现在不觉得自己像个白痴……在文档中完全忽略了这一点。谢谢大脑。
    猜你喜欢
    • 1970-01-01
    • 2012-01-30
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 2015-08-01
    • 1970-01-01
    相关资源
    最近更新 更多