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

Commit 7eda51a

Browse files
committed
nav provider at app level, fix ref for getNav
1 parent bbf3a00 commit 7eda51a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/createBrowserApp.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import { createBrowserHistory } from 'history';
44
import React from 'react';
5-
import { NavigationActions, getNavigation } from '@react-navigation/core';
5+
import {
6+
NavigationActions,
7+
getNavigation,
8+
NavigationProvider,
9+
} from '@react-navigation/core';
610

711
/* eslint-disable import/no-commonjs */
812
const queryString = require('query-string');
@@ -89,7 +93,11 @@ export default function createBrowserApp(App) {
8993
() => this.props.screenProps,
9094
() => this._navigation
9195
);
92-
return <App navigation={this._navigation} />;
96+
return (
97+
<NavigationProvider value={this._navigation}>
98+
<App navigation={this._navigation} />
99+
</NavigationProvider>
100+
);
93101
}
94102
_dispatch = action => {
95103
const lastState = this.state.nav;

src/handleServerRequest.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@ export default function handleServerRequest(
1414
// Get state from reducer
1515
const navigationState = Router.getStateForAction(navigationAction);
1616

17-
// Prepare top-level navigation prop
1817
const actionSubscribers = new Set();
19-
const navigation = getNavigation(
18+
19+
// Prepare top-level navigation prop
20+
let navigation = null;
21+
function getNavigation() {
22+
return navigation;
23+
}
24+
25+
navigation = getNavigation(
2026
Router,
2127
navigationState,
2228
() => {},
2329
actionSubscribers,
2430
() => ({}),
25-
() => navigation
31+
getNavigation
2632
);
2733

2834
// Get title from active screen options

0 commit comments

Comments
 (0)