Why does my app produce hydration errors when rendering VirtualizedList? #2252
Unanswered
DavidRieman
asked this question in
Help
Replies: 1 comment 2 replies
-
You can't expect the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having trouble setting up any kind of responsive virtualized list that just works. I'd run into a number of issues, but this one has multiple side effects that are super baffling. I'm putting my code through the react-native-web
examples
(just replacing theflatlist/index.js
) and the results are the same whether on 17.5, 17.7, or even with my VirtualizedList upgrades branch in play.The initial rendered items after a page refresh seem to be rendering as if the window width is zero. Console logging seemed to suggest that we're only rendering items with the intended width, but that's clearly not true. (I've now confirmed that Chrome's console log somehow misses the
console.log
entries that do attempt to get logged during first renders. Weird. But putting code likeif (!width) explode();
does explode as expected.)Then I see weird generic "Warning: prop style did not match" error that doesn't have enough detail to be clear why it exists or what the real problem is.
As soon as you do anything to cause another render, like drag the window a pixel wider, everything renders great.
Here's the code I'm using for this:
To repro, we can:
examples
pages.yarn examples
.It was weird that first
console.log
calls get missed by Chrome Dev Tools, but seems unlikely to be a react-native-web problem. (Maybe a weird Chrome optimization.) So let's skip that.It seems weird that
useWindowDimensions
is wrong on first read, but I can live with that - in this case I'd have to not render the List at all if width is 0. That may be get resolved during splash screens and the like for most real apps, but not the end of the world if (people in the know get to) apply an "if width <= 0, early out with blank view" work-around.But why doesn't the VirtualizedList re-render those first 4 items when the
renderer
function changed? Is that a clue to theprop style did not match
output - does some system notice that two renderings of an item in the list produced differing styles? Are responsive UI not technically supported while virtualizing? Perhaps this is exposing a timing bug? Maybe bad things will happen if you happen to catch any virtualizing list right between the initial items render and the second pass with a renderer-prop change... but the app refresh scenario is just the easiest way to repro the timing consistently?Beta Was this translation helpful? Give feedback.
All reactions