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: addComponentAsRefTo(...): Only a ReactOwner can have refs

See original GitHub issue

Trying to integrate react-select into our application and we’re seeing the following error. There may be something in our workflow that is causing it. We’re using ReactDOM to render react components into our page.

Uncaught Error: 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).

An example:

// other code
function init() {
  model.on('change', renderRecipientDisplay);
}

function logChange(val) { console.log("Selected: " + val); }

function renderRecipientDisplay() {
  var ReactSelect = require('react-select');
  var options = [{ value: 'one', label: 'One' }, { value: 'two', label: 'Two' }];

  ReactDOM.render(
    (
      <ReactSelect name="form-field-name" value="one" options={options} onChange={logChange} />
    ),
    $el.find('.routing-recipient-display')[0]
  );
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:19
  • Comments:34 (1 by maintainers)

github_iconTop GitHub Comments

45reactions
mockdeepcommented, Feb 11, 2016

We ended up giving up on react-select for the time being.

6reactions
cubbukcommented, May 4, 2016

Just for an information, I receive this error when I add a new dependency to the project. If I delete node_modules and reinstall all the dependencies the error does not occur again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not ......
Read more >
Refs Must Have Owner Warning - React
addComponentAsRefTo (…): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a...
Read more >
Fixing the Jest Error, "Invariant Violation
Invariant Violation : addComponentAsRefTo(…): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created ......
Read more >
`Error: Invariant Violation: addComponentAsRefTo(...): Only a ...
Coding example for the question Testing: `Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs.` error-Reactjs.
Read more >
Troubleshooting | React Redux
Invariant Violation : addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a ...
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