-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no force render on change #509
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks @alissaVrk will check it latter. One of advantages having a method to get virtual items is that we can get updated items in same render. Like in case of infinite reversed virtual list, the trick is to update scroll offset in same time when new data are prepend, calling get items will return correct items for new offset, more at discussion #195 (comment) Will this example work also so smooth when scrolling up? https://codesandbox.io/s/beautiful-meninsky-fr6csu?file=/pages/index.js
Ooo that is interesting, didn't see that before. Can you create codesandbox example? |
about the reverse scroll, the only problematic line that I see there is I will try it with my version. about the "tearing" I couldn't recreate in a sandbox yet |
ah, now I see the issue. |
the reverse scroll works ok, would you like me to add it to the infinite scroll example? is there a way to publish the package somewhere? it's very hard to link, I get duplicate react / react-dom. btw, do we need to support react 17? |
Great! It make sense as
That's why this is bin suprpsing 🤔 Overall still not sold by this, what would be real benefit to make this change that would justify the complexity? Other than
I think not, but i think we can create custom react-virtual and mimic the subscribeToChanges as basic it's just calling onChange. |
@alissaVrk you can use this in your project for test ( imho will work the same ) https://codesandbox.io/p/sandbox/crazy-cookies-brjtc0?file=%2Fsrc%2Freact-virtual%2Findex.tsx |
did not understand this. benefits:
I think it's simpler for the user |
another question, can we add |
ah, you mean import only the core and implement the react part locally - ok but temporarily, I don't think it's a good idea in the long run :) |
no, basic just create a file with your impl and update the import's paths, don't need to publish.
no, it's not :) it's tow re-renders, one for start and one for end, of course if range didn't change.
hmm items are not triggering the re-render, i think mention that before.
That most cases is wrong, as it's optimized to fast. For example when you got a list with count 100, and visible range is from 0-10, getting new items, and updating the list to count of 150, will also re-render items form 0-10 even they didn't change. Further more position of item should not trigger it re-render, that's why best is to memo rows item not the virtualization.
hmm, i agree that you meed to have some knowledge, but i think simpler would to work on docs 🤔 |
I tested, it does solve my bug... I will try to reproduce in a sandbox, but it won't be easy.. since it's timing |
with the force-render the state is basically the same (in parts) so react doesn't really know what changed about the complexity, I think most of it should move inside the core, and then there is no additional code, just a bit different. and using I think it's always better to make a more intuitive lib for the people using it, most people don't really read the docs :) |
btw, I think the library is really great :) |
@alissaVrk yeah, this is great, thanks for all your work! Will talk with others at @TanStack and get back to you. |
@piecyk I guess it didn't pass? :) |
Triaging as out of date. Please reopen a fresh PR if still valid. |
isScrolling
is not directly in the state anymore, because I don't think it's a good reason to render the component -> I have added the ability to register to isScrolling change.it probably would be better to make some of these changes in the core, but
I left the onChange option, but I would remove it - can't see why would anyone use it
Will happily update the docs if the idea will pass :)
** I would have also subtracted the scrollMargin from the virtualItems start and end