react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

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

Open shakogele opened this issue 7 years ago • 4 comments

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

shakogele avatar Dec 18 '18 10:12 shakogele

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 .

ItsNoHax avatar Dec 18 '18 11:12 ItsNoHax

Navigation.registerComponentWithRedux('navigation.playground.WelcomeScreen', () => WelcomeScreen, Provider, store); this works thanks

shakogele avatar Dec 20 '18 11:12 shakogele

pass a custom React context provider to and the corresponding React context consumer to Connect(Login) in connect options.

found this error in my machine when being compiled the code...any one have solution?.. thanks in Advance.

kuttenajith avatar Jan 30 '19 05:01 kuttenajith

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

developerabhijeet avatar Mar 23 '21 06:03 developerabhijeet