React 18 Support
See original GitHub issueUpdate: the issue is solved. Component should work out of the box.
The latest version of react-virtuoso seems to be working fine with React 18, except for increased “blinking” when scrolling upwards through unevenly sized items. ~~
For now, I have found a remedy (calling
flushSyncat the right moment), but it triggers dev mode warnings in React 16/17. The code could detect the React version, but it’s not reliable, as you might be running React 18 in compatible mode. So the fix is activated using thereact18ConcurrentRenderingproperty - see sample.
If you discover any problems in React 18, please comment here. Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How to Upgrade to React 18
In this release, React is dropping support for Internet Explorer, which is going out of support on June 15, 2022. We're making this...
Read more >React 18 Upgrade Guide and New Features - Refine Dev
React 18 was released! Are you looking to upgrade to React 18? Learn about the new features and changes in this comprehensive guide....
Read more >How to Upgrade to React 18 - How-To Geek
In this article, we'll show you how to upgrade your existing codebases to React 18. Bear in mind that this guide is only...
Read more >An Ultimate Guide to Upgrading to React 18 - OpenReplay Blog
The React team recently released React 18 with improvements like automatic batching, a new suspense feature, and new APIs like startTransition .
Read more >React 18 - What Changes Does It Bring And How Will They ...
React 18 drops support for Internet Explorer 11, even before the scheduled end of support from Microsoft. While you would expect the bundle...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The naming of the prop seems unfortunate since the issue is caused by automatic batching rather than concurrency. (React 18 does not use concurrency unless you opt into it with a specific concurrent feature like startTransition.) It also seems unfortunate that people using the latest version of React need to add a special prop.
What is the warning you’re seeing in 17 with flushSync?
@gaearon Tried that. The scroll compensation logic works correctly, but the blinking is still there.
To make matters more complicated, the sequence of the margin setting/scrolling by should be tweaked depending on the value (code). As far as I can see, I can’t control this through
useLayoutEffect.Ultimately, I think I found a solution through direct dom access, here’s the relevant part.
Again, thanks for your input. This react-virtuoso library is dealing with messy browser edge cases, so I’m fine with introducing workarounds so that its users don’t have to do so. The
flushSynccall seems conceptually right to me, and the only problem is its inconsistent behavior across 17 and 18.