Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit 8cc9069

Browse files
committed
fix: add peer dep on react-navigation
1 parent cc37ff4 commit 8cc9069

25 files changed

+74
-121
lines changed

.eslintrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55

66
"env": {
77
"es6": true,
8-
"react-native-globals/all": true,
8+
"react-native-globals/all": true
9+
},
10+
11+
"settings": {
12+
"import/core-modules": ["react-native-screens"]
913
},
1014

1115
"rules": {
12-
"import/no-unresolved": "off",
16+
"import/named": "off",
1317
"react-native/no-inline-styles": "off"
1418
}
1519
}

example/App.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import * as React from 'react';
22
// eslint-disable-next-line no-unused-vars
33
import { View, TouchableOpacity, FlatList, I18nManager } from 'react-native';
4-
import { ThemeContext, ThemeColors } from '@react-navigation/core';
5-
import { Themed, createAppContainer } from '@react-navigation/native';
4+
import {
5+
ThemeContext,
6+
ThemeColors,
7+
Themed,
8+
createAppContainer,
9+
} from 'react-navigation';
610
import { createStackNavigator } from 'react-navigation-stack';
711
import { MaterialCommunityIcons } from '@expo/vector-icons';
812
import { List, Divider } from 'react-native-paper';

example/metro.config.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ module.exports = {
2222
providesModuleNodeModules: [
2323
'@expo/vector-icons',
2424
'@babel/runtime',
25-
'@react-navigation/core',
26-
'@react-navigation/native',
27-
'react-native-gesture-handler',
28-
'react-native-reanimated',
2925
...dependencies,
3026
...peerDependencies,
3127
],

example/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
},
1111
"dependencies": {
1212
"@expo/vector-icons": "^10.0.0",
13-
"@react-navigation/core": "^3.5.0",
14-
"@react-navigation/native": "^3.6.0",
1513
"expo": "^34.0.0",
1614
"expo-asset": "^6.0.0",
1715
"expo-constants": "~6.0.0",
@@ -22,6 +20,7 @@
2220
"react-native-paper": "^2.2.0",
2321
"react-native-reanimated": "~1.1.0",
2422
"react-native-webview": "~5.12.0",
23+
"react-navigation": "^4.0.1",
2524
"react-navigation-stack": "^1.4.0"
2625
},
2726
"devDependencies": {

example/src/GestureInteraction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { Button, View } from 'react-native';
3-
import { withNavigation } from '@react-navigation/core';
3+
import { withNavigation } from 'react-navigation';
44
import {
55
createDrawerNavigator,
66
DrawerGestureContext,

example/src/ParallaxDrawer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import {
77
StyleSheet,
88
View,
99
} from 'react-native';
10-
10+
import { ThemeColors, useTheme, Themed, SafeAreaView } from 'react-navigation';
1111
import { createStackNavigator } from 'react-navigation-stack';
12-
import { ThemeColors, useTheme } from '@react-navigation/core';
13-
import { Themed, SafeAreaView } from '@react-navigation/native';
14-
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
15-
import Animated from 'react-native-reanimated';
1612
import { createDrawerNavigator } from 'react-navigation-drawer';
13+
import Animated from 'react-native-reanimated';
14+
import { MaterialIcons } from '@expo/vector-icons';
1715

1816
const SampleText = ({ children }) => <Themed.Text>{children}</Themed.Text>;
1917

example/src/RTLDrawer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
TouchableOpacity,
88
} from 'react-native';
99

10-
import { Themed } from '@react-navigation/native';
10+
import { Themed } from 'react-navigation';
1111
import { createStackNavigator } from 'react-navigation-stack';
1212
import { createDrawerNavigator } from 'react-navigation-drawer';
1313

example/src/SimpleDrawer.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import React from 'react';
22
import { Button, ScrollView, StyleSheet, View } from 'react-native';
33
import { createStackNavigator } from 'react-navigation-stack';
4-
import { ThemeColors, useTheme } from '@react-navigation/core';
5-
import { Themed, SafeAreaView } from '@react-navigation/native';
6-
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
4+
import { ThemeColors, useTheme, Themed, SafeAreaView } from 'react-navigation';
75
import { createDrawerNavigator } from 'react-navigation-drawer';
6+
import { MaterialIcons } from '@expo/vector-icons';
87

98
const SampleText = ({ children }) => <Themed.Text>{children}</Themed.Text>;
109

example/src/StyledDrawer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import { Button, ScrollView } from 'react-native';
33
import { createStackNavigator } from 'react-navigation-stack';
4-
import { Themed, SafeAreaView } from '@react-navigation/native';
5-
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
4+
import { Themed, SafeAreaView } from 'react-navigation';
65
import { createDrawerNavigator } from 'react-navigation-drawer';
6+
import { MaterialIcons } from '@expo/vector-icons';
77

88
const SampleText = ({ children }) => <Themed.Text>{children}</Themed.Text>;
99

example/yarn.lock

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@
918918
query-string "^6.4.2"
919919
react-is "^16.8.6"
920920

921-
"@react-navigation/native@^3.6.0":
921+
"@react-navigation/native@^3.6.2":
922922
version "3.6.2"
923923
resolved "https://registry.yarnpkg.com/@react-navigation/native/-/native-3.6.2.tgz#3634697b6350cc5189657ae4551f2d52b57fbbf0"
924924
integrity sha512-Cybeou6N82ZeRmgnGlu+wzlV3z5BZQR2dmYaNFV1TNLUGHqtvv8E7oNw9uYcz9Ox5LFbiX+FdNTn2d6ZPlK0kg==
@@ -4352,9 +4352,9 @@ react-native-safe-area-view@^0.12.0:
43524352
hoist-non-react-statics "^2.3.1"
43534353

43544354
react-native-safe-area-view@^0.14.1:
4355-
version "0.14.7"
4356-
resolved "https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-0.14.7.tgz#e1dd1c4d25a90677df2c15347fdddb2306ba5971"
4357-
integrity sha512-fmuBYpvKDJK33bimo4JXrK2BN2CGw7nof1y1LDRgzqv+FZ3eADSDGshprN8WeQqSZjQ20hJx1CiWk28Edg/v4Q==
4355+
version "0.14.8"
4356+
resolved "https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-0.14.8.tgz#ef33c46ff8164ae77acad48c3039ec9c34873e5b"
4357+
integrity sha512-MtRSIcZNstxv87Jet+UsPhEd1tpGe8cVskDXlP657x6rHpSrbrc+y13ZNXrwAgGNNhqQNX7UJT68ZIq//ZRmvw==
43584358
dependencies:
43594359
hoist-non-react-statics "^2.3.1"
43604360

@@ -4440,6 +4440,14 @@ react-navigation-stack@^1.4.0:
44404440
dependencies:
44414441
prop-types "^15.7.2"
44424442

4443+
react-navigation@^4.0.1:
4444+
version "4.0.1"
4445+
resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-4.0.1.tgz#96c17ac90afcf0a5bc957358152326211a79d183"
4446+
integrity sha512-6XzuqvhOnY6FA6tCErD6+vfZdnP+O/7hCQper9qDulxxW2ZVkCF4xWdzoVcv3DDR6P5CK6l1tcbJ1ku256AdFQ==
4447+
dependencies:
4448+
"@react-navigation/core" "^3.5.0"
4449+
"@react-navigation/native" "^3.6.2"
4450+
44434451
react-proxy@^1.1.7:
44444452
version "1.1.8"
44454453
resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-1.1.8.tgz#9dbfd9d927528c3aa9f444e4558c37830ab8c26a"

jest-setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-env jest */
22

3+
// eslint-disable-next-line import/no-unresolved
34
import NativeModules from 'NativeModules';
45

56
Object.assign(NativeModules, {

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
"@commitlint/config-conventional": "^7.5.0",
4747
"@expo/vector-icons": "^10.0.1",
4848
"@react-native-community/bob": "^0.3.4",
49-
"@react-navigation/core": "^3.5.0",
50-
"@react-navigation/native": "^3.6.2",
5149
"@release-it/conventional-changelog": "^1.1.0",
5250
"@types/jest": "^24.0.11",
5351
"@types/react": "^16.8.13",
@@ -70,19 +68,19 @@
7068
"react-native-reanimated": "^1.2.0",
7169
"react-native-screens": "^1.0.0-alpha.23",
7270
"react-native-testing-library": "^1.7.0",
71+
"react-navigation": "^4.0.1",
7372
"react-test-renderer": "16.8.6",
7473
"release-it": "^12.3.6",
7574
"typescript": "^3.4.5"
7675
},
7776
"dependencies": {},
7877
"peerDependencies": {
79-
"@react-navigation/core": "^3.5.0",
80-
"@react-navigation/native": "^3.6.2",
8178
"react": "*",
8279
"react-native": "*",
8380
"react-native-gesture-handler": "^1.0.12",
8481
"react-native-reanimated": "^1.0.0",
85-
"react-native-screens": "^1.0.0 || ^1.0.0-alpha"
82+
"react-native-screens": "^1.0.0 || ^1.0.0-alpha",
83+
"react-navigation": "^4.0.1"
8684
},
8785
"jest": {
8886
"preset": "react-native",
@@ -96,7 +94,7 @@
9694
"<rootDir>/example/"
9795
],
9896
"transformIgnorePatterns": [
99-
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation-deprecated-tab-navigator|@react-navigation/core|@react-navigation/native)"
97+
"node_modules/(?!(jest-)?react-native|react-navigation|@react-navigation/core|@react-navigation/native)"
10098
],
10199
"testPathIgnorePatterns": [
102100
"/node_modules/",

src/navigators/__tests__/createDrawerNavigator.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { View } from 'react-native';
33
import { render } from 'react-native-testing-library';
4-
import { createAppContainer } from '@react-navigation/native';
4+
import { createAppContainer } from 'react-navigation';
55

66
import createDrawerNavigator from '../createDrawerNavigator';
77

src/navigators/createDrawerNavigator.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import { Dimensions, Platform, ScrollView, I18nManager } from 'react-native';
3-
import { createNavigator, ThemeColors } from '@react-navigation/core';
4-
import { SafeAreaView } from '@react-navigation/native';
3+
import { createNavigator, ThemeColors, SafeAreaView } from 'react-navigation';
54
import DrawerRouter from '../routers/DrawerRouter';
65
import DrawerView from '../views/DrawerView';
76
import DrawerItems, { Props } from '../views/DrawerNavigatorItems';
@@ -53,6 +52,9 @@ const DefaultDrawerConfig = {
5352
const DrawerNavigator = (routeConfigs: object, config: any = {}) => {
5453
const mergedConfig = { ...DefaultDrawerConfig, ...config };
5554
const drawerRouter = DrawerRouter(routeConfigs, mergedConfig);
55+
56+
// TODO: don't have time to fix it right now
57+
// @ts-ignore
5658
const navigator = createNavigator(DrawerView, drawerRouter, mergedConfig);
5759
return navigator;
5860
};

src/routers/DrawerRouter.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import { SwitchRouter, NavigationActions } from '@react-navigation/core';
1+
import {
2+
SwitchRouter,
3+
NavigationActions,
4+
NavigationAction,
5+
NavigationRoute,
6+
} from 'react-navigation';
27
import * as DrawerActions from './DrawerActions';
38

4-
type Route = {
5-
key: string;
6-
index?: number;
7-
routes?: Route[];
8-
};
9-
10-
type Action = {
11-
key: null;
12-
type: string;
13-
willShow: any;
14-
};
15-
16-
type State = Route & {
9+
type State = NavigationRoute & {
1710
isDrawerOpen?: any;
1811
};
1912

@@ -28,7 +21,7 @@ function withDefaultValue(obj: object, key: string, defaultValue: any): any {
2821
return obj;
2922
}
3023

31-
const getActiveRouteKey = (route: Route): string => {
24+
const getActiveRouteKey = (route: NavigationRoute): string => {
3225
if (
3326
route.routes &&
3427
typeof route.index === 'number' &&
@@ -61,7 +54,7 @@ export default (
6154
return {
6255
...switchRouter,
6356

64-
getActionCreators(route: Route, navStateKey: string) {
57+
getActionCreators(route: NavigationRoute, navStateKey: string) {
6558
return {
6659
openDrawer: () => DrawerActions.openDrawer({ key: navStateKey }),
6760
closeDrawer: () => DrawerActions.closeDrawer({ key: navStateKey }),
@@ -70,7 +63,7 @@ export default (
7063
};
7164
},
7265

73-
getStateForAction(action: Action, state: State) {
66+
getStateForAction(action: NavigationAction, state?: State) {
7467
// Set up the initial state if needed
7568
if (!state) {
7669
return {

src/routers/__tests__/DrawerRouter.test.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
import * as React from 'react';
44
import DrawerRouter from '../DrawerRouter';
55

6-
import {
7-
NavigationActions,
8-
SwitchRouter,
9-
StackRouter,
10-
} from '@react-navigation/core';
6+
import { NavigationActions, SwitchRouter, StackRouter } from 'react-navigation';
117
import * as DrawerActions from '../../routers/DrawerActions';
128

139
const INIT_ACTION = { type: NavigationActions.INIT };

src/types.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DrawerActionType } from './routers/DrawerActions';
1+
import { NavigationAction } from 'react-navigation';
22

33
export type Route = {
44
key: string;
@@ -21,9 +21,5 @@ export type Navigation = {
2121
};
2222
openDrawer: () => void;
2323
closeDrawer: () => void;
24-
dispatch: (action: {
25-
type: DrawerActionType;
26-
key: string;
27-
willShow?: boolean;
28-
}) => void;
24+
dispatch: (action: NavigationAction) => boolean;
2925
};

src/views/DrawerNavigatorItems.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import { View, Text, StyleSheet, ViewStyle, TextStyle } from 'react-native';
3-
import { SafeAreaView } from '@react-navigation/native';
4-
import { ThemeContext } from '@react-navigation/core';
3+
import { SafeAreaView, ThemeContext } from 'react-navigation';
54
import TouchableItem from './TouchableItem';
65
import { Scene, Route } from '../types';
76

src/views/DrawerSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { StyleSheet, View, Animated, ViewStyle } from 'react-native';
3-
import { NavigationActions } from '@react-navigation/core';
3+
import { NavigationActions } from 'react-navigation';
44

55
import { Props as DrawerNavigatorItemsProps } from './DrawerNavigatorItems';
66
import { Navigation, Scene, Route } from '../types';

src/views/DrawerView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import * as React from 'react';
22
import { Dimensions, StyleSheet, ViewStyle } from 'react-native';
3-
import { SceneView, ThemeColors, ThemeContext } from '@react-navigation/core';
3+
import {
4+
SceneView,
5+
ThemeColors,
6+
ThemeContext,
7+
NavigationProp,
8+
} from 'react-navigation';
49
import { ScreenContainer } from 'react-native-screens';
510

611
import * as DrawerActions from '../routers/DrawerActions';
@@ -35,7 +40,7 @@ type Props = {
3540
navigation: Navigation;
3641
descriptors: {
3742
[key: string]: {
38-
navigation: {};
43+
navigation: NavigationProp<any>;
3944
getComponent: () => React.ComponentType<{}>;
4045
options: DrawerOptions;
4146
};

src/views/ResourceSavingScene.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as React from 'react';
44
import { Platform, StyleSheet, View } from 'react-native';
5-
65
import { Screen, screensEnabled } from 'react-native-screens';
76

87
type Props = {

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"noUnusedLocals": true,
1919
"noUnusedParameters": true,
2020
"resolveJsonModule": true,
21-
"skipLibCheck": true,
2221
"strict": true,
2322
"target": "esnext",
2423
"plugins": [{ "name": "typescript-tslint-plugin" }]

0 commit comments

Comments
 (0)