question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invariant Violation running example

See original GitHub issue

I ran the following commands to set up the example:

npm install
npm install react
npm install react-dom
npm run build
npm run build:example
cd example
node server

And when I open up localhost:3000 I see this error:

localhost/:45 Uncaught Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
drewencommented, May 13, 2017

@NickyYo Sounds like you have an issue with multiple reacts. If you’re making a reusable component that includes react-ace, make sure react/react-dom are in devDependencies and peerDependencies, not dependencies (http://stackoverflow.com/questions/30451556/what-is-the-correct-way-of-adding-a-dependency-to-react-in-your-package-json-for).

This gets funky when you use npm link because that doesn’t install in the same way; it’s just a symlink to the linked dependency, which means it’ll pull in all of the installed dependencies, including the manually install react/react-dom. If you use a bundler like webpack, you can alias all import of react by putting this in the resolve section:

alias: {
  'react': path.resolve(path.join(__dirname, 'node_modules', 'react')),
  'react-dom': path.resolve(path.join(__dirname, 'node_modules', 'react-dom'))
}

This forces all component to use the base project’s react modules.

0reactions
securingsincitycommented, May 13, 2017

Thanks @drewen !

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL mutation - Must contain a query definition
I'm using the @rest call from the Apollo Client docs. They use a gql query string, followed by a client.query({ query }) api...
Read more >
Invariant Violation: Must contain a query definition.
Invariant Violation: Must contain a query definition. Luan Marques. client.mutate({ mutation: gql` mutation { addTeam(input:{name:"Somename" ...
Read more >
invariant violation viewproptypes has been removed - You.com
`ERROR Invariant Violation: ViewPropTypes has been removed from React Native. Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. ERROR ...
Read more >
Redux testing - Invariant violation error - Hao's learning log
Test suite failed to run Invariant Violation: You must pass a ... SpendPointsMenu in this case is the Component in my example above, ......
Read more >
"Application has not been registered" error
When developing an Expo or React Native app, it's not uncommon to run into an error that looks like ... Invariant Violation: "main"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found