Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs
See original GitHub issueTrying 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:
- Created 8 years ago
- Reactions:19
- Comments:34 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We ended up giving up on
react-select
for the time being.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.