Store not passed via Provider to imported components in library projects with ver 6.0.0
See original GitHub issueThis issue occurs in 6.0.0, and is not seen in 5.0.7.
In this case, the component library was created with create-react-library. That child project was pulled in as a dependency, and its containers and reducers referenced in the consuming project.
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "^5.0.7", (^6.0.0 fails with 'store not found')
"react-scripts": "2.1.3",
"redux": "^4.0.1",
const store = createStore(
someApp,
applyMiddleware(
thunkMiddleware
)
)
ReactDOM.render(
<Routes store={store} />, document.getElementById('root'));
const Routes = (props) => (
<Provider {...props}>
<Router history={hashHistory}>
Issue Analytics
- State:
- Created 5 years ago
- Comments:31 (10 by maintainers)
Top Results From Across the Web
Module not found: Can't resolve 'swiper/react' - Stack Overflow
Here is my code. // Import Swiper React components import { Swiper, SwiperSlide } from "swiper/react" ...
Read more >connected-react-router - npm
Start using connected-react-router in your project by running `npm i ... Synchronize router state with redux store through uni-directional ...
Read more >xport 'switch' (imported as 'switch') was not found in 'react-router ...
reduxjs/react-reduxStore not passed via Provider to imported components in library projects with ver 6.0.0#1166. Created almost 4 years ago.
Read more >Configuring Your Store | Redux
First, we need to import redux-thunk plus our loggerMiddleware and monitorReducerEnhancer , plus two extra functions provided by Redux: ...
Read more >How to integrate React Hooks into your project without ...
{ "name": "app2", "version": "0.1. · import React, { Component } from 'react'; import Routes from './routes'; const App = () => {...
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
This is a bug. Please read OP’s text more closely. He is not asking for help.
The bug manifests itself if react-redux version 6 is used in a NPM module that exports some connected React component. The NPM module itself has no redux store and provider, but when you import that module it says that the base component that is exported from the same module needs to be wrapped with a Provider component.
So it happens if react-redux is a peer dependency
This was a pain to track down. Version 5.0.7 does not manifest the above behavior.
I ejected the app, added an alias for
react-redux
like the snippet below and it worksSo I guess the problem is that for some reason it loads the wrong version of
react-redux
. I still haven’t figured out where it finds it though. Bothmy-app
andmy-private-package
use v6.0