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.

Error: addComponentAsRefTo(...)

See original GitHub issue

I’m trying to use react-infinite-calendar in an existing react app. These are my steps:

  1. because our webpack config excludes node_modules, webpack wouldn’t run the loaders needed by react-infinite-calendar, therefore I created 2 new loaders in our webpack config:

        {
            test: /\.jsx?$/,
            loaders: ['babel'],
            include: /react-infinite-calendar/
        },
        {
            test: /(\.scss|\.css)$/,
            loaders: ['style', 'css?sourceMap&modules&importLoaders=1&localIdentName=Cal__[name]__[local]!postcss!sass?sourceMap'],
            include: /react-infinite-calendar/
        }
    
  2. when I run the application i get the following error

invariant.js:38 Uncaught (in promise) Error: 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).(…)

The calendar does not render successfully as a result of the exception: screen shot 2016-08-04 at 16 19 35

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
nickcancommented, Apr 12, 2017

@clauderic Sorry for bothering. We were able to figure this out. We needed to add “React” to an externals field in our Webpack config. We then found out that npm link breaks the external/peer dependency tree. So, the combo of externals and npm install --save ../path/to/package works.

Just wanted to let you know so you don’t waste your time responding here. Thanks

0reactions
nickcancommented, Apr 11, 2017

Also, as part of my investigation, I ended up refactoring our private package to take a calendar prop. Then in our app, I pass InfiniteCalendar as the prop. That works. Obviously not ideal or a solution my team and I are going to move forward with, but it helped me realize that including the project “higher up” worked. Thanks

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 >
reactjs - addComponentAsRefTo error when using component ...
I do a nmp link in the storybook in order to use it in my project. I can see the component, but it...
Read more >
Refs Must Have Owner Warning - React
Warning: addComponentAsRefTo(…): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a...
Read more >
Developers - Error: addComponentAsRefTo(...): Only a ReactOwner ...
Error : addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside...
Read more >
Fixing the Jest Error, "Invariant Violation
Jest sometimes fails with an error, "Invariant Violation: addComponentAsRefTo". This how-to discusses a solution for the error & speculates ...
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