Hi,
I am getting the following error in my Meteor project which uses react-apollo. The stack trace points me to react-apollo, so I am posting here, but I am not 100% convinced this issue belongs here.
W20170707-15:58:37.473(-4)? (STDERR) TypeError: Cannot read property 'ReactCurrentOwner' of undefined
W20170707-15:58:37.474(-4)? (STDERR) at Object.<anonymous> (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/react-apollo/node_modules/react-dom/cjs/react-dom-server.development.js:3534:36)
W20170707-15:58:37.474(-4)? (STDERR) at Module._compile (module.js:569:30)
W20170707-15:58:37.474(-4)? (STDERR) at Object.Module._extensions..js (module.js:580:10)
W20170707-15:58:37.475(-4)? (STDERR) at Module.load (module.js:503:32)
W20170707-15:58:37.475(-4)? (STDERR) at tryModuleLoad (module.js:466:12)
W20170707-15:58:37.475(-4)? (STDERR) at Function.Module._load (module.js:458:3)
W20170707-15:58:37.476(-4)? (STDERR) at Module.require (module.js:513:17)
W20170707-15:58:37.476(-4)? (STDERR) at require (internal/module.js:11:18)
W20170707-15:58:37.476(-4)? (STDERR) at Object.<anonymous> (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/react-apollo/node_modules/react-dom/server.js:6:20)
W20170707-15:58:37.477(-4)? (STDERR) at Module._compile (module.js:569:30)
=> Exited with code: 1
I did some searching, and read that this is due to version mismatches between react and react-dom.
The odd thing is that my package.json has both of these packages version locked on 15.6.1, so I'm thinking it's a dependency issue:
"react": "15.6.1",
"react-apollo": "^1.4.2",
"react-dom": "15.6.1",
If I upgrade them both to a 16.0.0-alpha.X release, the TypeError goes away:
"react": "16.0.0-alpha.12",
"react-apollo": "^1.4.2",
"react-dom": "16.0.0-alpha.12",
The unfortunate part about that is while it gets the project to build, upgrading to the 16.x alpha breaks other parts of the app. I am using react-native-web as well in this project, which requires a 15.x version.
I noticed that one of my package dependencies specifies react-native 0.46.1 as a dependency, which uses react 16.0.0-alpha.12. I'm using yarn, and I'm not sure how it figures out which version of react or react DOM to use when so many different versions are specified across my project's dependencies.
Is it possible that react 16.x is being loaded in parallel with react dom 15.x, which is causing the issue? Is there a way to "force" a certain version (15.6.1) be used?
Same issue here.
in the package.json react-dom is a optional dependency
"optionalDependencies": {
"react-dom": "0.14.x || 15.* || ^15.0.0 || ^16.0.0-alpha"
},
the v16 bit was added on April 27th in https://github.com/apollographql/react-apollo/commit/85a8b7f6a03d40ed8b1b21ace73a941d6f02633b for React Native compatiablity
I had to cd node_modules/react-apollo and run npm remove react-dom to fix the issue.
I don't understand why I have this in yarn.lock:
react-apollo@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/react-apollo/-/react-apollo-1.4.3.tgz#be18bfe7f6609263f3ff623308f88108152a7573"
dependencies:
apollo-client "^1.4.0"
graphql-anywhere "^3.0.0"
graphql-tag "^2.0.0"
hoist-non-react-statics "^2.0.0"
invariant "^2.2.1"
lodash.flatten "^4.2.0"
lodash.isequal "^4.1.1"
lodash.isobject "^3.0.2"
lodash.pick "^4.4.0"
object-assign "^4.0.1"
prop-types "^15.5.8"
optionalDependencies:
react-dom "0.14.x || 15.* || ^15.0.0 || ^16.0.0-alpha"
Last line is buggy
Removing the optionalDependencies, cleaning up the node_modules folder and re-ran yarn solved the issue for me.
Any update on this? It breaks a lot. Can you please remove alpha stuff from optionalDependencies? Thank you.
Temp fix for package.json
"postinstall": "rimraf node_modules/react-apollo/node_modules/react-dom"
Looks like this was fixed in a recent PR—https://github.com/apollographql/react-apollo/pull/828/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2L87
Could we release a new version?
@pk-nb new issue will be out ASAP!
Closing since this is fixed in master and will be out today
Confirmed that everything is back to normal on my end after upgrading react-apollo to 1.4.4!
Most helpful comment
Looks like this was fixed in a recent PR—https://github.com/apollographql/react-apollo/pull/828/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2L87
Could we release a new version?