Help with React-Redux connect - Could not find "store"
See original GitHub issueHi,
I am having issues when trying to use react-redux connect to connect React component to redux store.
I have looked at the redux helpers examples here https://ryandrewjohnson.github.io/react-localize-redux-docs/#redux-helpers and it looks like it should work with react-localize-redux (unless the redux helpers example is not using react-redux).
I used the code sandbox demo (https://codesandbox.io/s/14xp1xy9ql) and added react-redux to the dependencies list and added the following code to Main.js
const mapStateToProps = state => {
currentLanguage: getActiveLanguage(state.localize).code;
};
export default connect(mapStateToProps)(Main);
But I received the following error.
Could not find "store" in either the context or props of "Connect(Main)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(Main)".
Anyone knows what I am missing?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (3 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 >Accessing the Store | 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 >Could not find “store” in the context of connect ? : r/react - Reddit
I tried to solve it using mockStore and wrapping the component around Shallow and Provider.I applied this strategy in my Bill.test.js and App....
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 >
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 Free
Top 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
Yes, I initially thought LocalizeProvider is meant to replace react-redux’s Provider. Wrapping the application with Provider and LocalizeProvider as follows seems to solve the issue (assuming this is the proper way of doing it)
Docs need to be more clear about this issue. Also, if you wish to use
withLocalize
HOC to get thetranslate
function prop in your components, you must provide store prop toLocalizeProvider
. So the example code block would look something like this: