I'm getting this error and I googled solutions, but it seems like everything should be set up correctly.
Full error is: "Invariant Violation: Could not find "store" in the context of "Connect(AppComponent)". Either wrap root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(AppComponent) in connect options.
This error is located at: in Connect(AppComponent) (at renderApplication.js:34) in RCTView (at View.js:45) in View (at AppContainer.js:98) in RCTView (at View.js:45) in View (at AppContainer.js:115) in AppContainer (at renderApplication.js:33)
This is my code:
index.js
import { Provider } from 'react-redux'
import { createStore } from 'redux';
import App from './app/App';
import appState from './app/redux/reducers';
import {name as appName} from './app.json';
let store = createStore(appState);
export default class AppRoot extends Component {
render() {
return (
<Provider store={store}>
<App/>
</Provider>
);
}
}
AppRegistry.registerComponent(appName, () => App);
App.js
//import...
class AppComponent extends Component {
//code..
}
const mapStateToProps = (state, props) => {
return {}
};
const mapDispatchToProps = (dispatch, props) => {
return {
onFavoriteChange: (id, type) => {
switch(type){
//cases...
}
}
}
};
const App = connect(
mapStateToProps,
mapDispatchToProps
)(AppComponent);
export default App;
index.js (in /reducers)
import { combineReducers } from 'redux';
//imports...
let appState = combineReducers({
//all import...
});
export default appState;