react-native: undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner')

Description

The last couple of days I’ve been attempting to debug the current React Native master (updated the HEAD a few times) on either iOS or Android, however app execution fails immediately after receiving the bundle with the exception:

undefined is not an object (evaluating 'ReactInternals.ReactCurrentOwner')

I’ve attempted clean app rebuilds many times:

watchman watch-del-all
rm -rf ./node_modules
yarn cache clean
rm -rf $TMPDIR/react-*
yarn install
npm start -- --reset-cache

Also, cleaned the Android builds (./gradlew clean) and iOS builds (“Clean” and “Clean Build Folder”) and rebuilt.

Reproduction Steps and Sample Code

  1. Check out RN master.

  2. Build the Android libs using:

./gradlew installArchives
  1. Check in the resultant android/ directory (force add as it’s .gitignore’d) and push to a Github branch.

  2. In a RN app swap from the NPM published package to the published branch e.g.

yarn remove react-native
yarn add github:benjamin-dobell/react-native#builds/dynamic-toolbar
  1. Rebuild the app cd android; ./gradlew clean; ./gradlew installDebug, or for iOS from XCode.

  2. Launch the RN packager:

yarn start

Note: If you haven’t grabbed flowtype from master this will fail here. I just temporarily replaced the spread operator usage in type definitions with copy and paste contents.

  1. Launch the app on an Android or iOS device. Wait for the packager to bundle the package.

Error then occurs.

It’s perhaps worth noting that, I believe, this is the exact procedure I’ve followed in the past to build and test (and eventually contribute back) my RN forks.

Solution

Unsure.

Additional Information

  • React Native version: 73fc439bc03b457d7bcebdb3fd230e470af52e38
  • Platform: Android & iOS
  • Development Operating System: macOS 10.12.4 (16E195)
  • Dev tools:
    • android-ndk-r10e
    • Xcode 8.3.2 (Build version 8E2002)
    • node v7.9.0
    • yarn 0.23.4
    • npm 4.2.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 24
  • Comments: 24 (6 by maintainers)

Most upvoted comments

@winterrain5 As I mentioned, make sure you’ve installed the correct version of React. If you’re using React Native 0.45:

yarn add react@16.0.0-alpha.12

I’m assuming that you also need to update this too if you have it?

"react-test-renderer": "16.0.0-alpha.12"

I could have sworn I updated my React peer dependency. Apparently not!

That was the cause. Sorry!

A note to anyone else trying to run RN from master. Double check the react version in RN’s package.json matches the one in your app’s yarn lockfile.

Hello I had same issue when migrating from recat native 0.42.1 to 0.47.0 I did the following and it fixed almost all my issues :

  • delete/remove yourProject/node-modules folder
  • set up package.json with “react”: “16.0.0-alpha.12” and “react-native”: “0.47.0”
  • npm install
  • cd android && gradlew clean
  • cd… && npm start – --reset-cache (some react native libraries I had had to be updated also to last version supporting 0.47)

i have the same question in my android project. how to fix it ? i, package.json: “dependencies”: { “react”: “16.0.0-alpha.12”, “react-native”: “0.45.1” }

i got the same problem after upgrading to 0.45

@tiofabby it works for me ,i used

"dependencies": {
    "react": "16.0.0-alpha.12",
    "react-native": "^0.47.2"
  }

@Benjamin-Dobell It worked. Thanks.