react-native-mock: Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js'

After adding and importing this lib, testing with jest shows errors for all test suites:

  ● Test suite failed to run

    Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js'
      
      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
      at Object.<anonymous> (node_modules/react-addons-perf/node_modules/react-dom/lib/ReactDebugTool.js:16:30)

Part of package.json:

{
  "dependencies": {
    "react": "16.0.0-alpha.12", 
    "react-native": "0.46.3",
    ...
  }
  "devDependencies": {
    "jest": "^20.0.4",                               // 20.0.4
    "react-dom": "16.0.0-alpha.12",
    "react-native-mock": "^0.3.1",                   // 0.3.1
    "react-test-renderer": "16.0.0-alpha.12",
    ...
  }
}

Those errors are raised from react-addons-perf which is depended by react-native-mock. The version of react-addons-perf is 15.4.2. I’m not sure whether it is related to the version of react (16.0.0-alpha.12).

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 43
  • Comments: 35 (1 by maintainers)

Most upvoted comments

A solution I found here was: Installing compatible react-dom version as devDependency. Some people on this thread are using React 16 and react-dom < 16. I think this is the problem.

All prop types have to be moved from React to the prop-types package to support React 16. Also, all propTypes from react-native are now imported from the root as viewPropTypes instead of from the View object. See the commit below for examples of porting. If no one has picked it up I will try to submit a PR tomorrow

https://github.com/cjcheshire/react-native-multi-slider/commit/6f0d2cb480ccd7190ea9a16e678864f96698d3b2#diff-c71c6f99b408b5a1afd81a3839ce5d4b

@gabceb We are tomorrow 😃

At GitPoint, we’re using @shqld’s fork (https://github.com/shqld/react-native-mock) and it’s working fine. I’d suggest using that until #130 is merged (hopefully soon…)

@RealOrangeOne , what is the plan to resolve this?

React 16 Beta is out and they have oficially said perf add-ons wont be coming back the same way it was before

https://github.com/facebook/react/issues/10294

The hook was moved from addons to a different location for React 16 as per https://github.com/facebook/react/commit/f2fc1822501456a26b458a17851319904ffabe2a. I’m trying to get this to work with mockery by switching the loader location and will report back if I am able to get it to work