Open dmitrika opened 4 years ago
Is the Virtualize HOC what you're looking for? Upon inspecting the elements in the demo, it looks like it renders/mounts the previous 2 and the 2 after. You can also increase the number slides to render/mount using overscan.
I haven't tried it though.
Hey guys :wave:
As a result of changes in https://github.com/oliviertassinari/react-swipeable-views/issues/453 right now after mounting all children are rendered.
My use case: I use
react-swipeable-views
on SERP for a listing preview gallery, each gallery has 5 pictures. So after mount, we might end up with Nx5 images to be loaded, even if only N of them would be visible.I would like to propose API change to be able to provide a prop to change a number of slides to be rendered in advance:
Something like this... I'm not sure if it's aligned with initial ideas, I'm ready to implement this, first want to verify with repo maintainers.
Expected Behavior
I was expecting lazy loading to prevent over-fetching via rendering only active element (means downloading the only active picture), or at least active + 1.
Current Behavior
On mount we render all children.
Steps to Reproduce (for bugs)
Check out default code-sandbox example to verify that all children rendered. https://codesandbox.io/s/x8x11zjmp
Test case: https://github.com/oliviertassinari/react-swipeable-views/blob/master/packages/react-swipeable-views/src/SwipeableViews.test.js#L614
Context
As far as I understood it was done to enable heavy views to be rendered in advance. But for me that looks like we completely removed "lazy-loading" feature, we just skip rendering on the server. In case of images, all of them would be loaded on the client.
Your Environment