react: Error: performUpdateIfNecessary: Unexpected batch number ...
From maintainers: if you have this problem, please see the explanation in https://github.com/facebook/react/issues/6895#issuecomment-281405036.
I am getting a strange error I’ve never come across. Googling it doesn’t help at all.
Error: performUpdateIfNecessary: Unexcpeted batch number (current 36, pending 31)(...)
It has caused me a lot of headaches. I’ve reverted to 2 days ago and the error persists, even though 2 days ago everything was running smoothly and all tests were passing.
I would appreciate any sort of direction as to how I can begin to resolve this bug. My guesses are that it’s an error with Redux, Webpack, Redux-Form, or React itself. I know, not that precise, but I’m quite lost.
Example redux logger information:

Max OS X, El Capitan 10.11.5 React v15.0.1 (error persists on v15.1.0)
I’m sorry if this isn’t specific to React. I did look into the error message code and it appears to be coming from the Facebook/React code.
Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 55 (4 by maintainers)
Commits related to this issue
- Make "unexpected batch number" a warning This was added to catch internal errors in React but doesn't seem to be doing much good except frustrating people more when their apps throw (#6895, FB-intern... — committed to sophiebits/react by sophiebits 8 years ago
- Make "unexpected batch number" a warning (#7133) This was added to catch internal errors in React but doesn't seem to be doing much good except frustrating people more when their apps throw (#6895, F... — committed to facebook/react by sophiebits 8 years ago
- Make "unexpected batch number" a warning (#7133) This was added to catch internal errors in React but doesn't seem to be doing much good except frustrating people more when their apps throw (#6895, F... — committed to facebook/react by sophiebits 8 years ago
- GetNodes: Shuffle around to return an array of nodes This lets us use initial slugs that may map to multiple nodes (e.g. a per-repo slug) instead of the old keys which had to be one-to-one with nodes... — committed to wking/depviz by wking 8 years ago
- GetNodes: Shuffle around to return an array of nodes This lets us use initial slugs that may map to multiple nodes (e.g. a per-repo slug) instead of the old keys which had to be one-to-one with nodes... — committed to wking/depviz by wking 8 years ago
If anyone’s reading this through search or the like, the error seems to come up when you’re improperly destructing variables with an undefined value in it
const { value } = "undefined";It could also be an issue with your react-reduxconnectfunction. More specifically, my error was mapping (mapStateToProps) an undefined value to props with redux-form.To solve my issue, I had to remove entire components to see if my app would render correctly with or without them. Turned out to be a pretty good strategy after a few hours of headaches. This approach may help you isolate the issue. You’re most likely looking for
undefinedbeing passed along or assigned somewhere.Overall, React is behaving correctly in this instance and you’ve overlooked a different possible issue. Good luck 💆
This is definitely a React bug though. There’s nothing Redux Form is doing that would be wrong. So if you can repro, please share a case!
@mgnrsb and everyone else:
If you only saw this error but didn’t see the original error (for example in @mgnrsb’s case it would be something like “Cannot read target property of null”) then you still have a problem, and some part of your code swallows exceptions.
The most common way to get this problem is when you use Promises and have a catch() block after you’re attempting to update the UI. If a component throws an error (due to mistake in your code) your catch() handler gets this error and tries to render the error in the UI, assuming it is a network error. However the UI is already broken at this point because of the earlier error (which you never surface) and this is why you get a confusing second error.
Be careful catching errors especially when dealing with Promises. It is very easy to accidentally catch errors in your own code.
On Thu, Nov 24, 2016 at 04:50:27AM -0800, Dan Abramov wrote:
It makes a bit more sense before you boil it down that far 😉. The full version of that code is a graph of issues for each requested slug, so there’s a recursive slug-fetcher. The nested atomic state pivots allow me to avoid duplicate parallel calls 1.
@viz We’re using redux-form v6.2.0 and react v15.4.0 with no issues at the moment. We’ve also been using redux-form v6.x since alpha with no issues from react.
I would go over and try to identify the exact source of the issue. Try removing components until you narrow it down. Then I’d advise checking all the variables you’re using in that component and making sure you’re not passing around
undefinedanywhere.Or, as @gaearon suggested, provide an easy to follow example reproducing the issue.
We might want to look if it’s possible to have the invariant see correct numbers even if user code throws.
Here’s a fairly minimal project which reproduces this error in the test suite (shortly before the test legitimately errors out):
I got this error when trying to access
e.target.valuefrom an event that bubbles up from an input element into a custom element. By the time I want to consume it, the event has already been reset to null.const GeneralInput = ({ name, onChange }) => ( <input name={ name } onChange={ onChange } /> )I solved it by calling
e.persist()on the input element itself:const GeneralInput = ({ name, onChange }) => ( <input name={ name } onChange={ (e) => e.persist(); onChange(e) } /> )