naver / egjs-infinitegrid

A module used to arrange card elements including content infinitely on a grid layout.
https://naver.github.io/egjs-infinitegrid/
MIT License
2.23k stars 95 forks source link

React MasonryInfiniteGrid not updating when new data is passed in #487

Closed astralmedia closed 2 years ago

astralmedia commented 2 years ago

Description

When I pass new data into the array map that displays the items, it keeps the old positioning and does not reflow the layout to the new content...I've tried so much, any ideas?

Steps to check or reproduce

`return <MasonryInfiniteGrid column={columnCount} gap={5} ref={gridRef} loading={

LOAD

} onRequestAppend={getNextRequest}

{_.get(listData, "length", 0) > 0 && listData.map((item, index) => { const listTemplate = getTemplate(item, index) return listTemplate })} `

daybrush commented 2 years ago

@astralmedia

Even if the size of the item changes, it cannot be easily detected.

Use the useResizeObserver, observeChildren option or

Try calling the updateItems() method.

astralmedia commented 2 years ago

That hit the spot! Thank you friend