Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Cannot read property 'ReactCurrentOwner' of undefined #83

Closed
rwieruch opened this issue Oct 24, 2017 · 3 comments
Closed

Cannot read property 'ReactCurrentOwner' of undefined #83

rwieruch opened this issue Oct 24, 2017 · 3 comments

Comments

@rwieruch
Copy link
Member

rwieruch commented Oct 24, 2017

If you have started to read the ebook before the 4th edition was released, but grabbed the 4th edition recently (which uses React 16), you may see the following command line error message when executing your Jest tests for the first time:

FAIL  src/App.test.js
  ● Test suite failed to run

    TypeError: Cannot read property 'ReactCurrentOwner' of undefined

      at node_modules/react-test-renderer/cjs/react-test-renderer.development.js:621:36
      at Object.<anonymous> (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:8254:3)
      at Object.<anonymous> (node_modules/react-test-renderer/index.js:6:20)
      at Object.<anonymous> (src/App.test.js:3:26)
          at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.656s

You need to upgrade your project to React 16. Check your package.json if you run an old version of React. If you do so, type the following on the command line:

npm i -g npm-check-updates
npm-check-updates -u
npm install

It is a global npm module that can be used to update your dependencies, such as react or react-dom, in your package.json file. I should’ve mentioned it in the first place, for people grabbing the new edition who have an old React version installed.

See also #84

@rwieruch
Copy link
Member Author

Note: Add in Change Log when node packages are upgraded when a new edition gets released.

@kafisher
Copy link

kafisher commented Nov 7, 2017

After upgrading to React 16 I get the following error after running npm test:

TypeError: Cannot read property 'createEvent' of undefined

I was able to fix it by reverting to the old version and explicitly setting

"devDependencies": { ... "react-test-renderer": "^15.5.4"}

in my package.json and running npm install again.

@rwieruch
Copy link
Member Author

Closing this because React 16 was a long time ago and I don't expect people to run into this anymore.

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

No branches or pull requests

2 participants