Could not find "store" in the context of "Connect(WelcomeScreen)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(WelcomeScreen) in connect options
Issue Description
Im getting the following error when I try to connect to Redux:
Could not find "store" in the context of "Connect(WelcomeScreen)". Either wrap the root component in a
Steps to Reproduce / Code Snippets / Screenshots
I am using React Native Navigation, in App.js I have the followng: // App.js
import { Navigation } from 'react-native-navigation';
import { Provider } from 'react-redux';
import WelcomeScreen from './src/screens/WelcomeScreen/WelcomeScreen';
import configureStore from './src/store/configureStore';
const store = configureStore();
Navigation.registerComponent(`dsprov1.WelcomeScreen`, () => WelcomeScreen, Provider, store );
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
stack:{
id: 'AppStack',
children: [
{
component: {
name: 'comp.WelcomeScreen',
options:{
topBar:{
title:{
text: "Welcome Screen"
}
}
}
}
}
]
}
}
});
});
In WelcomeScreen.js I have following:
//WelcomeScreen.js
import { connect } from "react-redux";
....
const mapStateToProps = (state) => {
return {
serviceTypes: state.serviceTypes.serviceTypes
};
};
export default connect(mapStateToProps)(WelcomeScreen);
And im getting the following error in android simulator:
Could not find "store" in the context of "Connect(WelcomeScreen)". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(WelcomeScreen) in connect options.
What I am doing wrong?
Thanks in Advance
Environment
- React Native Navigation version: ^2.1.3-patch.2
- React Native version: 0.57.8
- Platform(s) (iOS, Android, or both?): Android
- Device info (Simulator/Device? OS version? Debug/Release?): Nexus S API 27
When registering screens use registerWithRedux
On Tue, 18 Dec 2018 at 11:57, shakogele [email protected] wrote:
Issue Description
Im getting the following error when I try to connect to Redux: Could not find "store" in the context of "Connect(WelcomeScreen)". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(WelcomeScreen) in connect options Steps to Reproduce / Code Snippets / Screenshots
I am using React Native Navigation, in App.js I have the followng: // App.js import { Navigation } from 'react-native-navigation'; import { Provider } from 'react-redux';
import WelcomeScreen from './src/screens/WelcomeScreen/WelcomeScreen';
import configureStore from './src/store/configureStore'; const store = configureStore();
Navigation.registerComponent(dsprov1.WelcomeScreen, () => WelcomeScreen, Provider, store ); Navigation.events().registerAppLaunchedListener(() => { Navigation.setRoot({ root: { stack:{ id: 'AppStack', children: [ { component: { name: 'comp.WelcomeScreen', options:{ topBar:{ title:{ text: "Welcome Screen" } } } } } ] } } }); });
In WelcomeScreen.js I have following:
//WelcomeScreen.js
import { connect } from "react-redux"; .... const mapStateToProps = (state) => { return { serviceTypes: state.serviceTypes.serviceTypes }; };
export default connect(mapStateToProps)(WelcomeScreen); And im getting the following error in android simulator: Could not find "store" in the context of "Connect(WelcomeScreen)". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(WelcomeScreen) in connect options. What I am doing wrong? Thanks in Advance Environment
- React Native Navigation version: ^2.1.3-patch.2
- React Native version: 0.57.8
- Platform(s) (iOS, Android, or both?): Android
- Device info (Simulator/Device? OS version? Debug/Release?): Nexus S API 27
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wix/react-native-navigation/issues/4469, or mute the thread https://github.com/notifications/unsubscribe-auth/AEBxyj17xNuVsSCwUosx2-B0hbtlht3Hks5u6MoygaJpZM4ZYEB7 .
Navigation.registerComponentWithRedux('navigation.playground.WelcomeScreen', () => WelcomeScreen, Provider, store);
this works thanks
pass a custom React context provider to
found this error in my machine when being compiled the code...any one have solution?.. thanks in Advance.
After resolving above error, I am getting following error:
TypeError: Cannot read property 'getState' of undefined (anonymous function) node_modules/react-redux/es/components/Provider.js:19