Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

TypeError: Cannot read property 'ReactCurrentOwner' of undefined #826

Closed
joncursi opened this issue Jul 7, 2017 · 9 comments
Closed

TypeError: Cannot read property 'ReactCurrentOwner' of undefined #826

joncursi opened this issue Jul 7, 2017 · 9 comments

Comments

@joncursi
Copy link

joncursi commented Jul 7, 2017

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?

@DogPawHat
Copy link

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 85a8b7f for React Native compatiablity

I had to cd node_modules/react-apollo and run npm remove react-dom to fix the issue.

@langpavel
Copy link

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

@zoltanarvai
Copy link

Removing the optionalDependencies, cleaning up the node_modules folder and re-ran yarn solved the issue for me.

@steida
Copy link

steida commented Jul 13, 2017

Any update on this? It breaks a lot. Can you please remove alpha stuff from optionalDependencies? Thank you.

@steida
Copy link

steida commented Jul 13, 2017

Temp fix for package.json

"postinstall": "rimraf node_modules/react-apollo/node_modules/react-dom"

steida added a commit to este/este that referenced this issue Jul 13, 2017
gabeweaver pushed a commit to verypossible/booster-kit-react that referenced this issue Jul 14, 2017
# Why
* The mocking is not working correctly.
* Tests are failing.
* Typings are off.

# What
* Adds a new `mockApollo` Provider that is a complete stand-in
replacement for `ApolloProvider` and `client`. It more or less creates
a mock networkInterface for Apollo, then uses a schema generated from
an introspection query against the JSON schema generated from the
server in order to provide Apollo with an executable schema it can
auto-mock against types (or use custom mocks passed in). It also has
support for passing in initial state, else it defers to the state
derived from the reducers.
* Fixes bug with test execution - `apolli-client` has an optional
dependency specified for react-dom 16.x. Removing it from `yarn.lock`
and reinstalling the packages solved the problem. [Open
Issue](apollographql/react-apollo#826)
* Fixes mock queries for `viewer`.
* Adds better type support for Graphql. Part of this includes removing
the `withData` higher order component for the time being until we can
figure out how to deal with some of the more complex type errors it was
producing. A complete example of the way to wrap a component with a
query can be found in `routes/docs/examples/grapqhl/root.tsx` with a
corresponding test in the same location.
* Adds a `mockGraphql` function for returning a mocked query outside of
a test - like if you want to mock some data out without making changes
to the server.
* Schema generation and type generation from the schema / used queries
is now fully automated. It triggers with `yarn run start` (Dev) and
`yarn run build` (Prod). This prevents the client from ever getting out
of sync with the server and enforces strict type checking on every
query, subscription, or mutation.
@pk-nb
Copy link

pk-nb commented Jul 14, 2017

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?

WickyNilliams added a commit to ONSdigital/eq-author that referenced this issue Jul 17, 2017
billyma128 pushed a commit to billyma128/qq888 that referenced this issue Jul 17, 2017
…of variables;fix button style;set query fetch-policy;fix select component style
@jbaxleyiii
Copy link
Contributor

@pk-nb new issue will be out ASAP!

@jbaxleyiii
Copy link
Contributor

Closing since this is fixed in master and will be out today

hamishtaplin pushed a commit to ONSdigital/eq-author that referenced this issue Jul 18, 2017
* basic question title/description/guidance editing

* fetch question type with questionnaire

* extract findById helper function

* fix tests for QuestionnaireDesignPage

* fix questionnaire creation to create new page as well as section

NOTE: this should be removed when API assumes this responsibility

* add fix for react-apollo dependency issues

see apollographql/react-apollo#826

* Allow API to create initial section and page for questionnaire

* additional tests to increase coverage

* make "builder" in nav link to first page

* rename prop for QuesitonnaireMetaPage "update" -> "onUpdate"

* convert null `value` prop to empty string in withChangeHandler

* oops

* update snapshots

* add snapshot test for QuestionnaireDesign

* remove use of withQuestionnaire HoC in QuestionnaireDesignPage

* fix Nav test
@joncursi
Copy link
Author

Confirmed that everything is back to normal on my end after upgrading react-apollo to 1.4.4!

steida added a commit to este/este that referenced this issue Aug 10, 2017
* Deps

* Simplify .babelrc for Jest

* styled props

- explicit context, because hoc typing sucks
- tests
- improved global styles
- and more

* Upgrade flow-bin, prop-types, flow-typed defs

* Fix link on pages index

* Wow, redux connect flow type inference works 100%

So we can remove unnecessary types.

* Update README.md

* Use real button with global reset

Less hacking

* all still doesn't work with flow v0.46.0

* Fix radio bug

* For future Relay Modern

* Fix link

* Update flow type defs

Yay, rada compose is fully typed!

* Update Apollo integration by updated Next.js example

* WIP: redux flat fields

* Move app higher order component to components dir

* Jest 20

* WIP

fields HOC is just a smart redux connect

* WIP

* Deps

* Rename Buttons to Fieldset

* Merge Field into TextInput

It belongs there.

* fields hoc

So this is super minimal typed implementation or previous Este fields.
But, it is really abstraction do we need?

* Fix TextInput test

* Deps

* WIP

- Rename Fields to Forms. It makes more sense, because we are dealing
with objects, not scalars.
- Normalise mutation API. Let’s have onPress for buttons, and onChange
for fields with value. No onTextChange nor onValueChange naming madness.
- onChange and onPress are required. That’s because… fields need it.
- Remove fields, it was wrong idea.

* Deps

* Remove unused code

* New Redux POC

- Remove payload mannerism
https://twitter.com/estejs/status/865686279702315008
- Change forms states manualy. Almost.
- I think we are close.

* Super minimal typed Redux form

- it’s fast, immutability ftw
- it’s typed (but flow sucks, Not covered by Flow for no reason, damn)
- it’s really easy and explicit

* Add yarn run upgrade

yarn upgrade should be enough, but node_modules can be misused, so
purge them to be sure

* eslint-config-airbnb 15

* Reuse existing type

* Flow...

* Ok, this seems to be good enough. Still weird a bit.

* A brand new simple yet powerful component ➡ Set

- It's something like Fieldset, but for everything. It has vertical and
spaceBetween props. A small thing but utterly useful.
- remove button margin horizontal, it’s up to Set
- move TextField error after label
- update deps
- some refactoring and progress here and there

* Add redux-persist

And now, all forms are automatically persisted in local storage.
Awesome.

* Improve storage keyPrefix

* Deps

* WIP

* Upgrade graphql, graphql-tag, flow-bin

* Simplify Checkbox and Radio, make label optional

Still, it should be one component imho.

* WIP

- forms reducer considered as anti-pattern

* Deps

Ramda 0.24 after it will be tested

* Delete selected users

* wip

- rename TOGGLE_SELECTED_USERS to TOGGLE_USERS_SELECTION
- emoticons in table headers
- small changes here and there

* redux-observable ftw

- universal UUID
- hot reloading reducers and epics stubs
- lib/form for reduceForm helper
- refactor user actions
- etc.

* Make reducers and epics hot reloadable

* Select user, fix things

* Finish redux forms logic example

- Now it is super fast by default
- Two simple rules: Do not nest state selections and… if needed, use
redux-virtualised.

* TextInput label size

It looks better when it’s the same.

* Deps

* yarn run prettier

* Yep, Node 8.0.0

* Move user table stuff to users-form

* Deps

* Beautify UsersTable

* Downgrade Node to 7.8.0

Because HMR is broken in 8.0.0

* Finish forms

- Fix things here and there.
- Render BrowserButton as div, because Firefox is a bitch.
- Add Form onSubmit, because div can’t submit. But that’s fine for
React Native.
- Fix Set alignItems

* Use React Children type

* Remove Redux actions boilerplate

- With Flow, we don’t need it.
- Epics deal with plain objects already.
- Better typing, more explicit code.
- Use explicit action names instead onFooBla naming patter.

* Rename AppState to ConfigState

Because it is.

* Fix bug, improve types to prevent it

* Inject typed dispatch

It’s better than cast it later.

* Prettify

* import type { Element } from 'react'

* WIP

- Add ValidationError and ValidationErrors types
- Simplify Form type props, add errors
- Require maxLength prop on TextInput
- Add ValidationError component
- Small changes here and there

* Deps

* Small Redux refactoring

* Form goodness ftw

- AppError type and component for app errors.
- ValidationError type and component, for guess what.
- Fix autoFocus via Focused component. It just works.
- Naive validation in epic.
- Some refactoring here and there.
- Esc to cancel editation mode.
- Soft some airbnb eslint rules.

* Clean UserForm

* Rename Focused to AutoFocus

* Simplify ValidationError

= {} because existential operator not yet in JS, but, soon will be.

* autoFocus scrollIntoView failback

* Deps

* Add required validation to Checkbox

* Flow 48, React 15.6

* Add validator

* No, maxLength should not be required.

It should be ok to overflow text length during editation for UX. Must
be validated elsewhere.

* Simple typed sync validation

* Node 8 and Next beta 3

* Prettier trailing comma for all

We can, because Node 8.

* Deps

* Improve validation

- Rename FormError to Errors, because we can validate any object.
- Rename error to appError, be explicit.
- Refactor validate to not break rxjs typing.

* Todo

* next 3.0.0-beta16

* Rename config back to app

* simulateUserSave

Insight, global app errors must be still app state locally saved to
specify context of error. Can be rendered as some global animated popup
on mobiles, but it’s just matter of UI.

* Improve AutoFocus scrolling logic. Scroll less.

* Add form disabled state

- Improve persist strategy. This is the best.
- Improve typing.

* Deps

* Improve Flow types

- remove hacky dispatch injection, be explicit
- because we are explicit, type checking is strict, not foking Not
covered shit.
- * aka existential type help a lot

* Validation for user table

- Even non-table tables can have growing rows, with little trick.
- AlertErrors component to render errors.

* Rename deploy-now to deploy

* Fela 5

* test

test test

* revert

* test

* test

* test

I am testing new Atom Github integration.

* ok

https://twitter.com/estejs/status/877296988068478977

* Rename fela.js to fela-renderer.js

* Basic intl

* Add support for multiple languages

- LocaleLink rewrites href if needed
- Fix .babelrc
- Preload app server state
- Add one msg
- etc.

https://medium.com/@steida/este-strategy-for-i18n-multiple-languages-8a0
f0162f176

* Next 3.0.1-beta.1

* Should not be required. Let's see.

* Comment rimraf-babel-cache

* Fix client / server rendering.

- server app state must be passed as initial
- fela must always clear itself

* I18n switch-locale

- fixes here and there

* Root href for default locale

* Improve react-intl flow types

 flow-typed/flow-typed#981

* I18n almost done

- use intl babel only for build, because build
- inject intl into all pages
- main-nav (like any other nav) reads from sitemap
- sitemaps defines pages and their titles
- improve i18n, extract messages should not be a part of build
- localize pages
- fixes here and there

* Do not pass serverState to Page

* Sort extracted messages

* Add basic buttons with translations

* Next 3.0.1-beta.2, dips

* I18n validation errors and other things

* Add some i18n examples

* Localize app error

* yep

* Prettier 1.5

* Comment not yet used code

* Add fixed Apollo Flow typedefs

* Remove misleading comment

* Add Apollo page

* Deps

* Add webpack-bundle-analyzer

* Remove apollo Flow

#1370 (comment)

* Use get-schema for versioning graph.cool

* Color 2 and Flow 0.49.1

* Add Loading component

* Deps

* Next 3.0.1-beta.6

* Add onSubmitEditing for TextInput

* Add Apollo example

* graph.cool CLI is cool

* Remove flex-start from Set

We don’t need it and it complicates layout.

* Yay finally, Eslint errors as warnings for dev.

* Add correct justifyContent for Checkbox and Radio

* Add SignIn page with AuthForm

Note super nice hack to overrideWebkitYellowAutofill.

* Localize AuthForm

* An optional onChange for Radio and Checkbox

* Add userGender typed enum

* Add alignContent to Box

* Fix bug in AlertErrors

* Deps

* Improve forms a lot!

- less typing, because better model
- faster, because less diff checks
- solved form disabled with Temp once for all. We don’t have to
customise persistence any more
- better types here and there

* TextInputBig

* Deps

* Remove flow ignore auth0-lock

I am not going to use it anyway. Client side code look bad and
graph.cool is working hard on that.

* Next 3.0.1-beta.9

And we can remove Flow ignore mitt.

* Remove withTheme, welcome injectTheme HOC

* Rename ThemeProps to ThemeProp

* Rename noFormId to initialFormId

Naming is hard.

* Deps

* Add default TextInput maxLength

* Fok that shit. Return withTheme.

Flow can’t reliable type inference HOC, so avoid it with withTheme, and
when we can’t, we have to redeclare exported type manually. Shit.
ReasonML ftw.

* Fok that shit.

* Deps

* Improve TextInputBig error

* SignIn client side and app errors

* Deps

* camelCase for gql queries

* Add ApolloClient and ServerState types, add apolloClient as dependency

* Update readme

* Auth progress

- Merge signIn and signUp actions into single auth action.
- Improve naming and translations.
- Add mutateAuth.
- Use exact type in app state as much as possible.

* Add AppError cannotSignInCredentialsInvalid

* Add cookie auth

* Deps with fix for react-apollo

apollographql/react-apollo#826 (comment)
5212452

* Auth resetStore and redirect

* Flow 0.50

* Deps

* Next.js 3.0.1-beta.14

* Fix bug

Damn dynamic code…

* Remove Apollo

* Add Relay

- move data stuff to data dir
- get actual graph.cool schema

* Next 3.0.1-beta.16

* Remove Apollo-client types

* From kebab-case to case sensitive file names

kebab-case seems to be Next.js standard, but case sensitive is React
Create App and Relay standard. I like it more when file names match JS
names.

* Temp commit before checkout

Damn, git handling case sensitive renaming.

* git mv foo.js Foo.js ftw

* Refactor gender into pure type

* Flat functional structure ftw

https://twitter.com/estejs/status/887109974018666496

* Disable eslint camelcase

* Fix yarn run relay, add comment to package.json 😱

https://medium.com/@steida/package-json-scripts-with-comments-771a364336
31

* Rename nom script relaySchema to schema

After all, it’s GraphQL anyway.

* Deps

* Add missing dep, relay-runtime

* Render posts with Relay Modern

Static queries with nested Relay containers is such a good design.

* Put Flow __generated__ into repo

To be honest, it’s because npm run relay does not work in Zeit now. I
also tried now files, but it seems to override everything else.

The good thing is, we can see and repo check generated Flow types.

* Relay 1.2.0-rc.1, fix Now deploy

* Improve npm script prettier

* Remove graphql dependency

import { graphql } from 'react-relay'; ftw

* Leverage process.env.NOW_URL

And fix naming ofc.

* Explain why TextInput maxLength is optional

* Going to respect React recommended naming for event handlers

It’s handler, so handle it. Also, onFooBla is event dispatcher name,
not the handler. OK.

* Deps, CreatePost, refactoring

I am pretty sure Redux will be replaced with declarative local state
based on Relay. Until it happen, we use redux for side effects and
handle all mutations in epics.

Soon, we will have app page Query with pending navigations and global
error handling. So close!

* Rename add to create

To be the same as GraphQL scheme.

* createRelayEnvironment, refactoring

* Flow 0.51

* Refactor, collocate, and simplify Flow types

Read IMPORTANT ADVICE! In types/index.

* Add CreatePost validation, refactoring

* Fix test file names casing

* yarn relay

* Improve AppError

* Create post

* createCommit helper

Remove RelayEnvironment. No type placeholders until properly flow-typed.

* Extract DeletePostButton

- rename Remove to Delete, because CRUD
- extract, because reusability

* Simplify imports

* Refactoring

* Fix typo

CREATE_USER_ERROR to CREATE_POST_ERROR

* Refactor AppError

While ValidationErrors are rendered locally, global app error should be
rendered globally and once.

* Remove AlertErrors

* Delete post

* Deps and little things here and there

* Pending navigations

After so many years of weak abstractions, we finally have it. Pending
navigations without pain. This is gold.

* Fix clientMutationId

It’s relic of iOS Relay. Not sure why it’s still required.

* Fix for CI

http://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshots-a
re-not-written-automatically-on-continuous-integration-systems-ci

* Fix CI

* Add first query variable

- fix rerending for the same url
- rename environment to getEnvironment

* Rename AllPosts to Posts

* Simplify DeletePostButton

Optimistic mutations don’t need Redux with observables to handle async
properly.

* Test circle ci 2

* Try add watchman

* Temp fix for circle ci 2

* ups

* try deploy to now from circleci

http://macklin.underdown.me/2017/07/27/deploy-to-now-from-circleci

* maybe

* OK, doesn't work for some reason

* Deps

* Relay Modern auth mutations, refactoring

* Fix AppError to now cover whole width

* Deps

* Comments

* Deps

* Add auth cookie

* Switch to next DB

Old demo links should work.

* Flow 0.52

* Email auth is done

* Back to default db

* Deps

* Enable flow linting

And disable some warnings

* Improve GraphQL example

* Add gravatar

* Cleaning

* Fix extractMessages

* Add confirm components

I think it’s very nice pattern.

* Error reporting with Sentry

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

No branches or pull requests

7 participants