Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Get initial action from the URL
const navigationAction =
Router.getActionForPathAndParams(path, query) || NavigationActions.init();
// Get state from reducer
const navigationState = Router.getStateForAction(navigationAction);
const actionSubscribers = new Set();
// Prepare top-level navigation prop
let navigation = null;
function getCurrentNavigation() {
return navigation;
}
navigation = getNavigation(
Router,
navigationState,
() => {},
actionSubscribers,
() => ({}),
getCurrentNavigation
);
// Get title from active screen options
const activeKey = navigationState.routes[navigationState.index].key;
const activeChildNavigation = navigation.getChildNavigation(activeKey);
const options = Router.getScreenOptions(activeChildNavigation);
const title = options.title || options.headerTitle;
return { navigation, title, options };
}
render() {
let navigation = this.props.navigation
const navState = this.state.nav
if (!navState) {
return null
}
if (!this._navigation || this._navigation.state !== navState) {
this._navigation = getNavigation(
Component.router,
navState,
this.dispatch,
this._actionEventSubscribers,
this._getScreenProps,
() => this._navigation
)
}
navigation = this._navigation
return (
)
}
render() {
let navigation = this.props.navigation;
if (this._isStateful()) {
const navState = this.state.nav;
if (!navState) {
return this._renderLoading();
}
if (!this._navigation || this._navigation.state !== navState) {
this._navigation = getNavigation(
Component.router,
navState,
this.dispatch,
this._actionEventSubscribers,
this._getScreenProps,
() => this._navigation
);
}
navigation = this._navigation;
}
invariant(navigation, 'failed to get navigation');
return (
render() {
this._navigation = getNavigation(
App.router,
this.state.nav,
this.dispatch,
this._actionEventSubscribers,
() => this.props.screenProps,
() => this._navigation
);
return (
);
}
dispatch = action => {
render() {
let navigation = this.props.navigation
const navState = this.state.nav
if (!navState) {
return null
}
if (!this.navigation || this.navigation.state !== navState) {
this.navigation = getNavigation(
Component.router,
navState,
this.dispatch,
this.actionEventSubscribers,
this._getScreenProps,
() => this.navigation
)
}
navigation = this.navigation
return (
)
}
): NavigationScreenProp => {
invariant(
router,
"App.router must be provided to createNavigationPropConstructor as of " +
"react-navigation-redux-helpers@2.0.0. Learn more: " +
"https://reactnavigation.org/docs/en/" +
"redux-integration.html#breaking-changes-in-2.3",
);
invariant(
getCurrentNavigation,
"getCurrentNavigation must be provided to createNavigationPropConstructor as of " +
"react-navigation-redux-helpers@2.0.0. Learn more: " +
"https://reactnavigation.org/docs/en/" +
"redux-integration.html#breaking-changes-in-2.3",
);
return getNavigation(
router,
state,
dispatch,
getReduxSubscribers(key),
getScreenProps,
getCurrentNavigation,
);
};
}