Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 2fb3712

Browse files
committed
Import from @react-navigation/core instead of react-navigation to maintain web compatibility
1 parent 9b1316a commit 2fb3712

6 files changed

Lines changed: 45 additions & 49 deletions

File tree

flow-typed/npm/react-navigation_v4.x.x.js renamed to flow-typed/npm/@react-navigation/core_v3.x.x.js

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
// flow-typed signature: 2cf86c1d5289a8ee234774a4d54dca33
2+
// flow-typed version: 536c492332/@react-navigation/core_v3.x.x/flow_>=v0.104.x
3+
14
// @flow
25

3-
declare module 'react-navigation' {
6+
declare module '@react-navigation/core' {
47

58
//---------------------------------------------------------------------------
69
// SECTION 1: IDENTICAL TYPE DEFINITIONS
@@ -216,7 +219,7 @@ declare module 'react-navigation' {
216219

217220
declare export type NavigationScreenOptionsGetter<Options: {...}> = (
218221
navigation: NavigationScreenProp<NavigationRoute>,
219-
ncreenProps: ?NavigationScreenProps,
222+
screenProps: ?NavigationScreenProps,
220223
theme: SupportedThemes,
221224
) => Options;
222225

@@ -606,16 +609,39 @@ declare module 'react-navigation' {
606609
...
607610
};
608611

612+
declare type _HeaderBackButtonProps = {|
613+
disabled?: boolean,
614+
onPress: () => void,
615+
pressColorAndroid?: string,
616+
tintColor?: ?string,
617+
backImage?: React$ComponentType<{
618+
tintColor: string,
619+
title?: ?string,
620+
...
621+
}>,
622+
title?: ?string,
623+
truncatedTitle?: ?string,
624+
backTitleVisible?: boolean,
625+
allowFontScaling?: boolean,
626+
titleStyle?: ?TextStyleProp,
627+
headerLayoutPreset: 'left' | 'center',
628+
width?: ?number,
629+
scene: NavigationStackScene,
630+
|};
631+
609632
declare export type NavigationStackScreenOptions = NavigationScreenOptions & {
610633
header?: ?(React$Node | (HeaderProps => React$Node)),
611634
headerTransparent?: boolean,
612-
headerTitle?: string | React$Node | React$ElementType,
635+
headerTitle?: (props: { children: ?string, ... }) => React$Node | React$Node,
613636
headerTitleStyle?: AnimatedTextStyleProp,
614637
headerTitleAllowFontScaling?: boolean,
615638
headerTintColor?: string,
616-
headerLeft?: React$Node | React$ElementType,
639+
headerLeft?: ((props: _HeaderBackButtonProps) => React$Node) | React$Node,
617640
headerBackTitle?: string,
618-
headerBackImage?: React$Node | React$ElementType,
641+
headerBackImage?: (props: {|
642+
tintColor?: string,
643+
title?: ?string,
644+
|}) => React$Node,
619645
headerTruncatedBackTitle?: string,
620646
headerBackTitleStyle?: TextStyleProp,
621647
headerPressColorAndroid?: string,
@@ -918,37 +944,4 @@ declare module 'react-navigation' {
918944
Component: ComponentType
919945
): React$ComponentType<$Diff<React$ElementConfig<ComponentType>, {| isFocused: ?boolean |}>>;
920946

921-
declare export function createAppContainer<S: NavigationState, O: {...}>(
922-
Component: NavigationNavigator<S, O, *>
923-
): NavigationContainer<S, O, *>;
924-
925-
declare export function createKeyboardAwareNavigator<Props: {...}>(
926-
Comp: React$ComponentType<Props>,
927-
stackConfig: {...}
928-
): React$ComponentType<Props>;
929-
930-
declare export function withOrientation<Props: {...}, ComponentType: React$ComponentType<Props>>(
931-
Component: ComponentType
932-
): React$ComponentType<$Diff<React$ElementConfig<ComponentType>, {| isLandscape: boolean |}>>;
933-
934-
declare type _SafeAreaViewProps = {
935-
forceInset?: _SafeAreaViewInsets,
936-
children?: React$Node,
937-
style?: AnimatedViewStyleProp,
938-
...
939-
};
940-
declare export var SafeAreaView: React$ComponentType<_SafeAreaViewProps>;
941-
942-
// These components take the same props that their React Native primitives do
943-
// Typing them correctly would be extremely brittle
944-
// We await the day we can import types from libraries in flow-typed libdefs
945-
declare export var ScrollView: React$ComponentType<{...}>;
946-
declare export var FlatList: React$ComponentType<{...}>;
947-
declare export var SectionList: React$ComponentType<{...}>;
948-
declare export var Themed: {|
949-
StatusBar: React$ComponentType<{...}>,
950-
Text: React$ComponentType<{...}>,
951-
TextInput: React$ComponentType<{...}>,
952-
|};
953-
954947
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "Ashoat Tevosyan (https://github.com/ashoat)",
77
"license": "BSD-2-Clause",
88
"repository": {
9-
"url": "[email protected]:react-navigation/react-navigation-redux-helpers.git",
9+
"url": "[email protected]:react-navigation/redux-helpers.git",
1010
"type": "git"
1111
},
1212
"dependencies": {
@@ -22,7 +22,7 @@
2222
],
2323
"peerDependencies": {
2424
"react": "*",
25-
"react-navigation": "*",
25+
"@react-navigation/core": "*",
2626
"redux": "*"
2727
}
2828
}

src/create-redux-container.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import type {
77
NavigationScreenProp,
88
NavigationNavigatorProps,
99
SupportedThemes,
10-
} from 'react-navigation';
10+
} from '@react-navigation/core';
1111

1212
import * as React from 'react';
13-
import { ThemeContext, NavigationProvider } from 'react-navigation';
13+
import { ThemeProvider, NavigationProvider } from '@react-navigation/core';
1414

1515
import {
1616
initializeListeners,
@@ -88,14 +88,14 @@ function createReduxContainer<
8888
this.getCurrentNavigation,
8989
);
9090
return (
91-
<ThemeContext.Provider value={this.theme}>
91+
<ThemeProvider value={this.theme}>
9292
<NavigationProvider value={this.currentNavProp}>
9393
<Navigator
9494
{...props}
9595
navigation={this.currentNavProp}
9696
/>
9797
</NavigationProvider>
98-
</ThemeContext.Provider>
98+
</ThemeProvider>
9999
);
100100
}
101101

src/middleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import type {
77
NavigationDispatch,
88
NavigationScreenProp,
99
NavigationRouter,
10-
} from 'react-navigation';
10+
} from '@react-navigation/core';
1111
import type { Middleware } from 'redux';
1212

1313
import invariant from 'invariant';
14-
import { getNavigation } from 'react-navigation';
14+
import { getNavigation } from '@react-navigation/core';
1515

1616
import { initAction } from './reducer';
1717

src/reducer.js

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

3-
import type { NavigationAction, NavigationState } from 'react-navigation';
3+
import type { NavigationAction, NavigationState } from '@react-navigation/core';
44
import type { Reducer } from 'redux';
55
import type { Navigator, ReducerState } from './types'
66

7-
import { NavigationActions } from 'react-navigation';
7+
import { NavigationActions } from '@react-navigation/core';
88

99
const initAction = NavigationActions.init();
1010

src/types.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// @flow
22

3-
import type { NavigationContainer, NavigationState } from 'react-navigation';
3+
import type {
4+
NavigationContainer,
5+
NavigationState,
6+
} from '@react-navigation/core';
47

58
export type Navigator = NavigationContainer<*, *, *>;
69
export type ReducerState = ?NavigationState;

0 commit comments

Comments
 (0)