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.

maybeSetState and pingpong unstable

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jeroenhoebecommented, Jan 13, 2017

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.

0reactions
STRMLcommented, Jan 23, 2017

@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):

screen shot 2017-01-23 at 9 39 44 am screen shot 2017-01-23 at 9 39 57 am
Read more comments on GitHub >

github_iconTop Results From Across the Web

maybeSetState and pingpong unstable · Issue #160 - GitHub
Hi, I'm getting the ReactList failed to reach a stable state. error message even if all my items are the exact same size....
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