Я пытаюсь реализовать редукцию и навигацию в собственном приложении реакции, поэтому я пытаюсь следовать инструкциям для реактивных помощников реагирования ( здесь ).
Кажется, я смог достичь экземпляра класса Root без проблем, но получил ошибку при попытке загрузки компонента:
App.js:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import { Provider, connect } from 'react-redux';
import rootReducer from './src/reducers/index';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { reduxifyNavigator, createReactNavigationReduxMiddleware, createNavigationReducer } from 'react-navigation-redux-helpers';
import LoginScreen from './src/screens/LoginScreen';
import NotesScreen from './src/screens/NotesScreen';
const AppNavigator = createStackNavigator({
Login: {
screen: LoginScreen
},
Notes: {
screen: NotesScreen
}
})
const navReducer = createNavigationReducer(AppNavigator);
const appReducer = combineReducers({
rootReducer,
navReducer
})
const middleware = createReactNavigationReduxMiddleware('root', state => state.nav);
const App = reduxifyNavigator(AppNavigator, 'root');
const mapStateToProps = state => ({
state: state.nav
})
const AppWithNavigationState = connect(mapStateToProps)(App);
const store = createStore(appReducer, applyMiddleware(middleware));
class Root extends React.Component {
render() {
return (
<Provider store={store}>
<AppWithNavigationState />
</Provider>
)
}
}