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.

Store not passed via Provider to imported components in library projects with ver 6.0.0

See original GitHub issue

This 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:closed
  • Created 5 years ago
  • Comments:31 (10 by maintainers)

github_iconTop GitHub Comments

8reactions
utajumcommented, Jan 30, 2019

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.

7reactions
gerhatcommented, Feb 3, 2019

I ejected the app, added an alias for react-redux like the snippet below and it works

alias: {
  // Support React Native Web
  // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
  'react-native': 'react-native-web',
  'react-redux': path.resolve('./node_modules/react-redux')
},

So 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. Both my-app and my-private-package use v6.0

Read more comments on GitHub >

github_iconTop 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 >

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