Replies: 1 comment 1 reply
-
|
I agree that we should recommend using render prop and introduce ReactElement caching(it doesn't pre-render DOM nodes, but pre-create React elements without mounting), but not sure what return components in render prop means. The reason why I recommend pre-created elements is historical, there were no render prop, I think render prop with caching will fit for 99% cases, but I still have some concerns and I don't want to obsolete any existing usecases, but I don't have enough time to go into the details. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What's the point of virtualizing pre-rendered DOM nodes, like in all the examples? It's much worse than using the render prop. The only scenario where this design may pay off is if you're absolutely sure the user will scroll through the whole huge list at least twice. Even in this case, it's not efficient to pre-render the whole list before displaying it.
A better pattern for such cases is caching: once an element has been rendered, store it so it doesn’t need to be rendered again. This avoids unnecessary re-renders without pre-rendering items the user may never see.
In practice, most users don’t scroll through giant lists multiple times. And if the list isn’t giant, there’s little reason to use virtualization in the first place.
My suggestion is:
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions