Could not find "store" in either the context or props
See original GitHub issueI 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:
- Created 8 years ago
- Reactions:9
- Comments:17 (7 by maintainers)
Top 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 >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
https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy#babel-legacy-decorator-plugin
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 usingbabel-plugin-transform-decorators-legacy
and set thecontextType
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
.