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.

Could not find "store" in either the context or props

See original GitHub issue

I get a Could not find "store" in either the context or props error whenever I try to connect a component to Redux.

When I’m in the debug console I can see that state is defined on this and context but it has a value of undefined. Also, when I inspect createStore I get an object back with dispatch, getState, etc.

import { Provider } from 'react-redux';
import React from 'react';
import reducers from '../config/reducers';
import { createStore } from 'redux';
import routes from '../config/routes';

React.render(
  <Provider store={ createStore(reducers) }>
    { () => routes }
  </Provider>
, document.body);

Component

import React from 'react';

// components
import Footer from './_footer';
import Header from './_header';

// redux
import { connect } from 'react-redux';

import ClientSessionActionCreators from '../../actions/client-session-action-creators';

class ApplicationLayout extends React.Component {
  render() {
    return (
      <div>
        <Header />
        { this.props.children }
        <Footer />
      </div>
    );
  }
}

export default connect(state => state)(ApplicationLayout);

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:9
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
lonelyclickcommented, Sep 30, 2016

https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy#babel-legacy-decorator-plugin

/// WRONG

"plugins": [
  "transform-class-properties",
  "transform-decorators-legacy"
]

// RIGHT

"plugins": [
  "transform-decorators-legacy",
  "transform-class-properties"
]
5reactions
D1plo1dcommented, Feb 23, 2016

I had a similar issue. Turned out that in babel 6 babel-plugin-transform-decorators-legacy does not handle class properties properly. If you are using babel-plugin-transform-decorators-legacy and set the contextType of your class using a static property babel is actually erroneously applying that static property to the decorated class (ie. the object returned by the connect decorator) instead of your original class.

Once I’ve got a test case to prove it I’m going to file an issue with babel-plugin-transform-decorators-legacy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Could not find "store" in either the context ...
It's pretty simple. You're trying to test the wrapper component generated by calling connect()(MyPlainComponent) .
Read more >
Could not find - "store" - in - either the context or props
It's saying your connected component cannot be rendered without a store. So, if your current call to shallow is like this: const wrapper...
Read more >
Help with React-Redux connect - Could not find "store" #102
Could not find "store" in either the context or props of "Connect(Main)". Either wrap the root component in a <Provider>, or explicitly pass ......
Read more >
Provider | React Redux
Could not find "store" in the context of "Connect(MyComponent)". Either wrap the root component in a <Provider> , or pass a custom React...
Read more >
Troubleshooting | React Redux
Could not find "store" in either the context or props​ · Make sure you don't have a duplicate instance of React on the...
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