Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Commit

Permalink
nav provider at app level, fix ref for getNav
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvicenti committed Oct 25, 2018
1 parent bbf3a00 commit 7eda51a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/createBrowserApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import { createBrowserHistory } from 'history';
import React from 'react';
import { NavigationActions, getNavigation } from '@react-navigation/core';
import {
NavigationActions,
getNavigation,
NavigationProvider,
} from '@react-navigation/core';

/* eslint-disable import/no-commonjs */
const queryString = require('query-string');
Expand Down Expand Up @@ -89,7 +93,11 @@ export default function createBrowserApp(App) {
() => this.props.screenProps,
() => this._navigation
);
return <App navigation={this._navigation} />;
return (
<NavigationProvider value={this._navigation}>
<App navigation={this._navigation} />
</NavigationProvider>
);
}
_dispatch = action => {
const lastState = this.state.nav;
Expand Down
12 changes: 9 additions & 3 deletions src/handleServerRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ export default function handleServerRequest(
// Get state from reducer
const navigationState = Router.getStateForAction(navigationAction);

// Prepare top-level navigation prop
const actionSubscribers = new Set();
const navigation = getNavigation(

// Prepare top-level navigation prop
let navigation = null;
function getNavigation() {
return navigation;
}

navigation = getNavigation(
Router,
navigationState,
() => {},
actionSubscribers,
() => ({}),
() => navigation
getNavigation
);

// Get title from active screen options
Expand Down

0 comments on commit 7eda51a

Please sign in to comment.