daybrush / infinite-viewer

Infinite Viewer is Document Viewer Component with infinite scrolling.
https://daybrush.com/infinite-viewer/
MIT License
283 stars 30 forks source link

[React][Question] New children don't get updated by infinite viewer when scrolling #69

Open mendesnathanj opened 8 months ago

mendesnathanj commented 8 months ago

I couldn't find any open issues or examples of this, but when i render elements under the InfiniteViewer component and they are added after the infinite viewer is initially rendered, then they aren't being updated via the translate effect that infinite viewer does.

Is there something on my end I'm missing or is it not something the library supports for now?

Items that exist initially render completely fine and don't have any issues

A simplified example would look like this

function App() {
  // items are initially empty
  const [items, setItems] = useState([]);

  // add a new item once a second
  useEffect(() => {
    setTimeout(() => {
       setItems((prev) => ([...prev, <div style={{ left: 50, top: 50 }} />]));
    }, 1000);
  }, []);

  return <InfiniteViewer>{items}</InfiniteViewer>;
}