expo / ex-navigation

Route-centric navigation for React Native
997 stars 201 forks source link

Cannot get it done with redux integration #436

Closed telmen closed 6 years ago

telmen commented 7 years ago

iOS version: 10.3 Model: iPhone 7+ not an emulator Hi, somehow I cannot integrate with redux. more information below. I'm getting following error screen image here is my store module

import { createNavigationEnabledStore, NavigationReducer } from '@expo/ex-navigation';
import { combineReducers, createStore } from 'redux';

const createStoreWithNavigation = createNavigationEnabledStore({
  createStore,
  navigationStateKey: 'navigation',
});

const store = createStoreWithNavigation(
  /* combineReducers and your normal create store things here! */
  combineReducers({
    navigation: NavigationReducer,
    // other reducers
  })
);

export default store;

and router module

import HomeScreen from '../screens/HomeScreen';
console.log('Router');
export const Router = createRouter(() => ({
  home: () => HomeScreen,
}));

index module which is combining both

import React, { Component } from "react";
import { View, Text, Image, Platform, StatusBar } from "react-native";
import { Provider } from "react-redux";
import {
  NavigationContext,
  NavigationProvider,
  StackNavigation,
  createRouter
} from "@expo/ex-navigation";
import Expo from "expo";
import Store from "./store/Store";
import Router from "./navigation/Router";

const navigationContext = new NavigationContext({
  router: Router,
  store: Store
});
class AppContainer extends Component {
  render() {
    return (
        <NavigationProvider context={navigationContext}>
        <Provider store={Store}>
          <StackNavigation initialRoute={Router.getRoute("home")} />
          </Provider>
        </NavigationProvider>
    );
  }
}

export default AppContainer;

And I'm using create-react-native-app. Using all of these

"@expo/ex-navigation": "^2.9.4",
    "babel-preset-react-native-stage-0": "^1.0.1",
    "expo": "15.1.2",
    "react": "~15.4.2",
    "react-native": "0.42.3",
    "react-redux": "^5.0.3",
    "redux": "^3.6.0",

can you help me?