mathieueveillard / react-beautiful-dnd-grid

Adds grid support to react-beautiful-dnd
MIT License
56 stars 18 forks source link

Not rerender grid if change props maxItems #5

Open malytinKonstantin opened 5 years ago

malytinKonstantin commented 5 years ago
<ListManager
  items={this.pages}
  direction="horizontal"
  maxItems={this.props.imageSize}
  render={this.$renderImageView}
  onDragEnd={this.handleDrop}
/>
atefBB commented 2 years ago

@malytinKonstantin did solve this issue ?!

AjayShivanagol commented 5 months ago

did anyone able to solve this ?

Quy1e99 commented 2 months ago

did anyone able to solve this ?

use cann add componentdisupdate to listen for the change of maxItems componentDidUpdate(prevProps: Omit<P, Props> & WithMaxItemsProps) { if (prevProps.maxItems !== this.props.maxItems || prevProps.items !== this.props.items) { const maxItems = this.props.maxItems && this.props.maxItems > 0 ? this.props.maxItems : this.props.items.length

    this.setState({
      maxItems,
      items: this.props.items,
      chunks: splitItems(maxItems, this.props.items, createId)
    })
  }
}