maybeSetState and pingpong unstable
See original GitHub issueHi,
I’m getting the ReactList failed to reach a stable state.
error message even if all my items are the exact same size. The error is reproductible by simply scrolling down just enough for the from
state to be updated and then scroll back up to go to the previous value of from
. Looking at the code, the unstable error message is triggered when there is a pingpong situation. The pingpong being the state unequal to the previous state but equal to the previous previous state. But in the situation I’ve described, the pingpong is normal.
Start
prevPrevState.from = 0;
prevState.from = 0;
state.from = 0;
Scrolling down pass the first element
prevPrevState.from = 0;
prevState.from = 0;
state.from = 1;
Scrolling back up (trigger the pingpong)
prevPrevState.from = 0;
prevState.from = 1;
state.from = 0;
Looking at the code, I’ve found that the reason why this happens is that the state
and the componentDidUpdate
are only triggered when there is a change in the value of the state. The reason is that the maybeSetState
only set the state if there is change. Commenting this line https://github.com/orgsync/react-list/blob/master/react-list.es6#L128 solves the issue.
Am I the only one having this issue? Is there any other solutions then what i’m proposing? Why is there a maybeSetState
method? Can this be removed?
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks! Type ‘variable’ now works for me without any errors.
ps. I didn’t really test it with type ‘uniform’ because the items aren’t the same height. Tried it but got (after some crazy scrolling) an infinite loop, it didn’t log the error anymore though.
@caseywebdev Anecdotally, the stack overflows in our production app have completely stopped as of
0.8.1
(I manually merged my own fix into production which was adapted into 0.8.3):(FF and Chrome throw different errors thus the different graphs):