Error: addComponentAsRefTo(...)
See original GitHub issueI’m trying to use react-infinite-calendar
in an existing react app. These are my steps:
-
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/ }
-
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:
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (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 >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 >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
@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 thatnpm link
breaks the external/peer dependency tree. So, the combo ofexternals
andnpm install --save ../path/to/package
works.Just wanted to let you know so you don’t waste your time responding here. Thanks
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