question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update: 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 flushSync at 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 the react18ConcurrentRendering property - see sample.

If you discover any problems in React 18, please comment here. Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Apr 26, 2022

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?

0reactions
petyosicommented, Apr 27, 2022

Is it possible to just call setMargin but then perform the scrollBy call in a layout effect? And use a ref to keep track of whether it already ran or not.

@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 flushSync call seems conceptually right to me, and the only problem is its inconsistent behavior across 17 and 18.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found