Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation reducer error #11

Open
jaksatomovic opened this issue Jan 1, 2019 · 0 comments
Open

Navigation reducer error #11

jaksatomovic opened this issue Jan 1, 2019 · 0 comments

Comments

@jaksatomovic
Copy link

jaksatomovic commented Jan 1, 2019

Hi somehow i am unable to run project with nav reducer from your code.
In order to make it work i had to create reducer inside AppNavigator like this:

const navReducer = createNavigationReducer(RootNavigator);
const reducer = combineReducers({
    nav: navReducer,
});

and change configureStore (in my case just store) to this:

const store = createStore(
    reducer,
    applyMiddleware(middleware, thunkMiddleware, loggerMiddleware),
);

App is still working the same I think after this changes...but i cant change the status bar now like u did

Here is the full code of AppNavigator.js

import {
    createStore,
    applyMiddleware,
    combineReducers,
} from 'redux';
import {
    reduxifyNavigator,
    createReactNavigationReduxMiddleware,
    createNavigationReducer,
} from 'react-navigation-redux-helpers';
import { createLogger } from 'redux-logger';
import thunkMiddleware from 'redux-thunk';
import { connect } from 'react-redux';
import React from 'react';
import RootNavigator from './RootNavigator'

const navReducer = createNavigationReducer(RootNavigator);
const reducer = combineReducers({
    nav: navReducer,
});


// Note: createReactNavigationReduxMiddleware must be run before reduxifyNavigator
const middleware = createReactNavigationReduxMiddleware(
    "root",
    state => state.nav,
);

const App = reduxifyNavigator(RootNavigator, "root");
const mapStateToProps = (state) => ({
    state: state.nav,
});

const AppWithNavigationState = connect(mapStateToProps)(App);

const loggerMiddleware = createLogger({ predicate: () => __DEV__ });

const store = createStore(
    reducer,
    applyMiddleware(middleware, thunkMiddleware, loggerMiddleware),
);

const Root = () => <AppWithNavigationState />;

export {
    store,
    Root,
};

I am using react-navigation v3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant