Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: this.updater.enqueueCallback is not a function when using setState callback #10320

Closed
wojtekmaj opened this issue Jul 28, 2017 · 11 comments

Comments

@wojtekmaj
Copy link

Do you want to request a feature or report a bug?

Bug on a beta version.

What is the current behavior?

image

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/84v837e9/).

In my Component, I used a pretty simple piece of code:

  doSomeMore = () => {
    // Do stuff
  }

  doSomething = (value) => {
    this.setState({ value }, this.doSomeMore );
  }

firing doSomething() causes this error.

What is the expected behavior?

I expect this.doSomeMore function to be called after this.setState from this.doSomething.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Version of React: 16.0.0-beta.2
I have tested several other versions and I can confirm that:

  • This bug also appears on 16.0.0-beta.1
  • This bug does NOT appear on 15.6.1
@gaearon
Copy link
Collaborator

gaearon commented Jul 28, 2017

From your stack trace it is visible that you have 15 of React package but 16 of ReactDOM. Can you try same versions please?

@aweary
Copy link
Contributor

aweary commented Jul 28, 2017

@gaearon should we maybe fail early or at least warn if we detect a major version mismatch?

@wojtekmaj
Copy link
Author

Oh damn, shame on me. Indeed it was a version mismatch.

@gaearon
Copy link
Collaborator

gaearon commented Jul 29, 2017

Closing since there is no issue. We can discuss warning on version mismatch in a separate issue if you would like!

@gaearon gaearon closed this as completed Jul 29, 2017
@bradennapier
Copy link

I am having this issue since updating to react 16 with lots of packages.

react-tooltip is one

react-google-maps is another

with my package.json showing:

    "react": "^16.0.0",
    "react-dom": "^16.0.0",

@gaearon
Copy link
Collaborator

gaearon commented Sep 26, 2017

Please run npm ls react. You'll find that some package brings in the wrong version of React because it puts it in dependencies rather than peerDependencies. Please file an issue with that project.

@bradennapier
Copy link

Cool, thanks Dan!

@bradennapier
Copy link

bradennapier commented Sep 26, 2017

So that did fix it. It was a module that is not actually included anywhere in my file anymore. May be worth adding something in the release notes to have the user run yarn list react or npm ls react to check their dependencies as you had said.

Removing that package seemed to fix all the issues instantly.

@ben-burlingham
Copy link

ben-burlingham commented Oct 18, 2017

For the record, I had this error from an Enzyme 3.0 adapter using a React 16 adapter, when my React version was 15.

Changing adapters solved the issue.

@vchaudhari
Copy link

I am facing following issue can anybody help me out
The issue occurs when I am trying to use callback function for react-x-editable component.

Uncaught TypeError: this.updater.enqueueCallback is not a function
at t.r.setState (editable.js:28)
at t.n.onSubmit (editable.js:28)
at HTMLUnknownElement.callCallback (react-dom.development.js:100)
at Object.invokeGuardedCallbackDev (react-dom.development.js:138)
at Object.invokeGuardedCallback (react-dom.development.js:187)
at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:201)
at executeDispatch (react-dom.development.js:461)
at executeDispatchesInOrder (react-dom.development.js:483)
at executeDispatchesAndRelease (react-dom.development.js:581)
at executeDispatchesAndReleaseTopLevel (react-dom.development.js:592)
at forEachAccumulated (react-dom.development.js:562)
at runEventsInBatch (react-dom.development.js:723)
at runExtractedEventsInBatch (react-dom.development.js:732)
at handleTopLevel (react-dom.development.js:4472)
at batchedUpdates$1 (react-dom.development.js:16537)
at batchedUpdates (react-dom.development.js:2131)
at dispatchEvent (react-dom.development.js:4551)
at interactiveUpdates$1 (react-dom.development.js:16592)
at interactiveUpdates (react-dom.development.js:2150)
at dispatchInteractiveEvent (react-dom.development.js:4528)
r.setState @ editable.js:28
n.onSubmit @ editable.js:28
callCallback @ react-dom.development.js:100
invokeGuardedCallbackDev @ react-dom.development.js:138
invokeGuardedCallback @ react-dom.development.js:187
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:201
executeDispatch @ react-dom.development.js:461
executeDispatchesInOrder @ react-dom.development.js:483
executeDispatchesAndRelease @ react-dom.development.js:581
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:592
forEachAccumulated @ react-dom.development.js:562
runEventsInBatch @ react-dom.development.js:723
runExtractedEventsInBatch @ react-dom.development.js:732
handleTopLevel @ react-dom.development.js:4472
batchedUpdates$1 @ react-dom.development.js:16537
batchedUpdates @ react-dom.development.js:2131
dispatchEvent @ react-dom.development.js:4551
interactiveUpdates$1 @ react-dom.development.js:16592
interactiveUpdates @ react-dom.development.js:2150
dispatchInteractiveEvent @ react-dom.development.js:4528

sbusch added a commit to sbusch/react-jsonschema-form that referenced this issue Oct 26, 2018
fixes version conflicts, e.g. I got an error

  Uncaught TypeError: this.updater.enqueueCallback is not a function when using setState callback

because I use React 16.x and react-jsonschema-form bundled react-dom 15.x

See facebook/react#10320 (comment)
glasserc pushed a commit to rjsf-team/react-jsonschema-form that referenced this issue Oct 26, 2018
fixes version conflicts, e.g. I got an error

  Uncaught TypeError: this.updater.enqueueCallback is not a function when using setState callback

because I use React 16.x and react-jsonschema-form bundled react-dom 15.x

See facebook/react#10320 (comment)
epicfaace pushed a commit to rjsf-team/react-jsonschema-form that referenced this issue May 22, 2019
* react-dom is external peerDependency, just like react.

fixes version conflicts, e.g. I got an error

  Uncaught TypeError: this.updater.enqueueCallback is not a function when using setState callback

because I use React 16.x and react-jsonschema-form bundled react-dom 15.x

See facebook/react#10320 (comment)

* Fix for new submit() method (PR #1058) also submitting the HTML form

..., navigating away from current page at least in Firefox. Reason:
dispatched event was not cancelable, so preventDefault in onSubmit
couldn't cancel it.

Links:

* <https://stackoverflow.com/a/40916998>
* <https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable>

* Synchronous call to onSubmit() from props

Due to the use of setImmediate() hack in setState utility function (utils.js),
onSubmit() handler from props is called asynchronously. This leads to massive
problems for operations requiring "trusted events", like window.open() or
programmatically submitting forms with target "_blank" (which we needed)

Because onSubmit() should not need the performance-related setImmiate() hack, I
replaced call to setState utility function with proper this.setState() from
React.

* fix failing FileWidget tests

by changing to proper use of setState() without setImmediate() hacks (see #1197)

* fix input type, fix test name

* Test with newer node versions

* Add node 12
@nikelborm
Copy link

nikelborm commented Jan 10, 2021

I have got the same error. My problem was the manual setting this.updater = null in my class constructor, but when I renamed it, problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants