profile
viewpoint

Ask questionsBug: Warning: unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering if debugger present

If a debugger is present in the main body of a functional component then on hitting the debugger and proceeding from there an unstable_flushDiscreteUpdates warning is thrown.

React version: ^16.13.1

Steps To Reproduce

  1. Clone https://github.com/kentcdodds/bookshelf
  2. Put a debugger right above the React.useEffect() in the DiscoverBooksScreen Component
  3. Hit the debugger break point and resume execution of code
  4. unstable_flushDiscreteUpdates warning is thrown in the console.

Link to code example: https://github.com/kentcdodds/bookshelf

The current behavior

unstable_flushDiscreteUpdates warning is thrown in the console

The expected behavior

unstable_flushDiscreteUpdates warning should not be thrown in the console

Untitled Untitled2

facebook/react

Answer questions kentcdodds

And it's not just something weird about the bookshelf app as @SangeetAgarwal notes:

I was able to reproduce this issue in an app written a couple of years back that used class components too

https://github.com/kentcdodds/bookshelf/issues/113#issuecomment-720100770

useful!
source:https://uonfu.com/
answerer
Kent C. Dodds kentcdodds @kentcdodds Salt Lake City, Utah, USA https://kentcdodds.com Improving the world w/ quality software · Husband, Father, Latter-day Saint, Teacher, OSS · http://TestingJavaScript.com · http://EpicReact.Dev · Be Kind
Github User Rank List