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

calling setProps causes "this.updater.enqueueCallback is not a function" #1199

Closed
alansouzati opened this issue Sep 29, 2017 · 7 comments
Closed

Comments

@alansouzati
Copy link

Enzyme version: 3.0.0
React version: 16.0.0

Test

import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });

test('Drop updates', () => {
  const onClose = jest.fn();
  const component = mount(<FakeInput onClose={onClose} />);
  component.setProps({ onClose: undefined });
  expect(component.getDOMNode()).toMatchSnapshot();
});

Error

TypeError: this.updater.enqueueCallback is not a function

      at WrapperComponent.Object.<anonymous>.ReactComponent.setState (node_modules/enzyme-adapter-utils/node_modules/react/lib/ReactBaseClasses.js:64:18)
      at WrapperComponent.setChildProps (node_modules/enzyme-adapter-utils/build/createMountWrapper.js:72:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:217:26)
      at ReactWrapper.setProps (node_modules/enzyme/build/ReactWrapper.js:418:24)
      at Object.<anonymous> (src/js/components/Drop/__tests__/Drop-test.js:114:13)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:109:7)

Any ideas what could be causing this?

@alansouzati
Copy link
Author

FYI, by investigating this further I noticed that node_modules/enzyme-adapter-utils has a react 15 version inside node_modules/enzyme-adapter-utils/node_modules.

As a test, I manually deleted that React folder and the issue goes away.

I tried to analyze the package.json for enzyme-adapter-utils and I could not find anything wrong (it correctly uses a peer dependency). So I have no idea why it still has a react 15 copy. 😢

@alansouzati
Copy link
Author

super weird. This problem seems to be with Yarn and the way they are handling peerDependencies.

If I use npm install it does not get the extra copy of React. I'm closing down this issue since I believe there is nothing to be fixed in your end.

@ljharb
Copy link
Member

ljharb commented Sep 29, 2017

If you file an issue on yarn, please link it here for posterity - thanks!

@alansouzati
Copy link
Author

yarnpkg/yarn#4590

@WickyNilliams
Copy link

Upgrading from yarn v1.1.0 to v1.2.1 fixed issue for me 👍

@javierfernandes
Copy link

javierfernandes commented Dec 12, 2017

I had the same issue while upgrading an app from react 15 to 16.
Upgrading yarn (to the latest version which is now 1.3.2) did do the trick :(

I had to manually override the transitive dependency in package.json like this

  "resolutions": {
    "enzyme-adapter-utils/react": "~16"
  },

Hopefully this will help others :)

@ljharb
Copy link
Member

ljharb commented Dec 14, 2017

@javierfernandes that doesn't sound like the right solution. You might not have the right dependency versions set up; overriding dependencies should never be required.

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

No branches or pull requests

5 participants