developerdizzle / react-virtual-list

Super simple virtualized list React component
http://developerdizzle.github.io/react-virtual-list/
MIT License
619 stars 73 forks source link

Added elements is not render #60

Closed cheesytim closed 5 years ago

cheesytim commented 6 years ago

Hi! I'am trying to add new elements at list, but added elements is not rendered. In screenshot the result of render function with my refreshing list and virtual argument

const MyList = ({ virtual, itemHeight, section }) => {
  console.log(virtual)
  return (
    <ListStyled>
      {virtual.items.map((row, index) => (
        <div key={index} style={{ display: 'flex'}}>
          {row.map((material) => (
            <MaterialListItem
              key={material.get('id')}
              material={material}
              section={section}
            />
          ))}
        </div>
      ))}
    </ListStyled>
)};

 splitIntoChunks = (list, chunkSize = 4) => {
    return Range(0, list.count(), chunkSize)
      .map(chunkStart => list.slice(chunkStart, chunkStart + chunkSize));
  }

  render() {
    const items = this.splitIntoChunks(this.props.materials).toList().toArray()
    console.log(items)
    const MyVirtualList = this.MyVirtualList;
    return (
      <div>
        <MyVirtualList
          items={items}
          itemHeight={130}
          section={this.props.section}
        />
...

2017-08-25 16 55 31

developerdizzle commented 6 years ago

Hi @Tim152, I haven't tested this with an array of lists, but theoretically it should work. Could you show the rest of your code, including the creation/assignment of this.MyVirtualList ?