refactor: import from /native instead of /core

This commit is contained in:
Satyajit Sahoo
2019-12-11 17:22:59 +01:00
parent 7b8277dae5
commit eef17a801e
60 changed files with 66 additions and 66 deletions

View File

@@ -35,7 +35,7 @@ Navigators bundle a router and a view which takes the navigation state and decid
A simple navigator could look like this:
```js
import { createNavigatorFactory } from '@react-navigation/core';
import { createNavigatorFactory } from '@react-navigation/native';
function StackNavigator({ initialRouteName, children, ...rest }) {
// The `navigation` object contains the navigation state and some helpers (e.g. push, pop)
@@ -256,7 +256,7 @@ Sometimes we want to run side-effects when a screen is focused. A side effect ma
To make this easier, the library exports a `useFocusEffect` hook:
```js
import { useFocusEffect } from '@react-navigation/core';
import { useFocusEffect } from '@react-navigation/native';
function Profile({ userId }) {
const [user, setUser] = React.useState(null);
@@ -285,7 +285,7 @@ The `useFocusEffect` is analogous to React's `useEffect` hook. The only differen
We might want to render different content based on the current focus state of the screen. The library exports a `useIsFocused` hook to make this easier:
```js
import { useIsFocused } from '@react-navigation/core';
import { useIsFocused } from '@react-navigation/native';
// ...

View File

@@ -1,7 +1,7 @@
import * as React from 'react';
import { View, TextInput, ActivityIndicator, StyleSheet } from 'react-native';
import { Title, Button } from 'react-native-paper';
import { ParamListBase } from '@react-navigation/core';
import { ParamListBase } from '@react-navigation/native';
import {
createStackNavigator,
HeaderBackButton,

View File

@@ -2,7 +2,7 @@ import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button } from 'react-native-paper';
import { useSafeArea } from 'react-native-safe-area-context';
import { RouteProp, ParamListBase } from '@react-navigation/core';
import { RouteProp, ParamListBase } from '@react-navigation/native';
import {
createStackNavigator,
StackNavigationProp,

View File

@@ -7,7 +7,7 @@ import {
RouteProp,
ParamListBase,
useFocusEffect,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { DrawerNavigationProp } from '@react-navigation/drawer';
import { StackNavigationProp } from '@react-navigation/stack';
import {

View File

@@ -1,7 +1,7 @@
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Button } from 'react-native-paper';
import { RouteProp, ParamListBase } from '@react-navigation/core';
import { RouteProp, ParamListBase } from '@react-navigation/native';
import {
createStackNavigator,
StackNavigationProp,

View File

@@ -6,10 +6,8 @@ import { Asset } from 'expo-asset';
import {
InitialState,
getStateFromPath,
NavigationContainerRef,
} from '@react-navigation/core';
import {
useLinking,
NavigationContainerRef,
NavigationNativeContainer,
} from '@react-navigation/native';
import {

View File

@@ -7,7 +7,7 @@ Bottom tab navigator for React Navigation following iOS design guidelines.
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/bottom-tabs
yarn add @react-navigation/native @react-navigation/bottom-tabs
```
Now we need to install [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).

View File

@@ -46,7 +46,7 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-safe-area-context": "^0.3.6"

View File

@@ -3,7 +3,7 @@ import {
useNavigationBuilder,
createNavigatorFactory,
DefaultNavigatorOptions,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
TabRouter,
TabRouterOptions,

View File

@@ -10,7 +10,7 @@ import {
NavigationProp,
ParamListBase,
Descriptor,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { TabNavigationState } from '@react-navigation/routers';
export type BottomTabNavigationEventMap = {

View File

@@ -13,7 +13,7 @@ import {
Route,
NavigationContext,
CommonActions,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { SafeAreaConsumer } from 'react-native-safe-area-context';
import BottomTabItem from './BottomTabItem';

View File

@@ -8,7 +8,7 @@ import {
ViewStyle,
TextStyle,
} from 'react-native';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import TabBarIcon from './TabBarIcon';
import { BottomTabBarButtonProps } from '../types';

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
type Props = {
route: Route<string>;

View File

@@ -7,7 +7,7 @@ Compatibility layer to write navigator definitions in static configuration forma
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/compat
yarn add @react-navigation/native @react-navigation/compat
```
## Usage

View File

@@ -32,7 +32,7 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "~16.9.0"
},
"@react-native-community/bob": {

View File

@@ -3,7 +3,7 @@ import {
NavigationProp,
ParamListBase,
RouteProp,
} from '@react-navigation/core';
} from '@react-navigation/native';
import ScreenPropsContext from './ScreenPropsContext';
import createCompatNavigationProp from './createCompatNavigationProp';

View File

@@ -1,4 +1,4 @@
import { CommonActions, NavigationState } from '@react-navigation/core';
import { CommonActions, NavigationState } from '@react-navigation/native';
export function navigate({
routeName,

View File

@@ -1,4 +1,4 @@
import { CommonActions } from '@react-navigation/core';
import { CommonActions } from '@react-navigation/native';
import { StackActions, StackActionType } from '@react-navigation/routers';
export function reset(): CommonActions.Action {

View File

@@ -4,7 +4,7 @@ import {
ParamListBase,
NavigationProp,
RouteProp,
} from '@react-navigation/core';
} from '@react-navigation/native';
import * as helpers from './helpers';
import { CompatNavigationProp } from './types';

View File

@@ -6,7 +6,7 @@ import {
TypedNavigator,
NavigationProp,
RouteProp,
} from '@react-navigation/core';
} from '@react-navigation/native';
import CompatScreen from './CompatScreen';
import ScreenPropsContext from './ScreenPropsContext';
import createCompatNavigationProp from './createCompatNavigationProp';

View File

@@ -2,7 +2,7 @@ import {
useNavigationBuilder,
createNavigatorFactory,
DefaultNavigatorOptions,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
TabRouter,
TabRouterOptions,

View File

@@ -1,4 +1,4 @@
import { ParamListBase, NavigationProp, Route } from '@react-navigation/core';
import { ParamListBase, NavigationProp, Route } from '@react-navigation/native';
import * as helpers from './helpers';
export type CompatNavigationProp<

View File

@@ -4,7 +4,7 @@ import {
useRoute,
NavigationProp,
ParamListBase,
} from '@react-navigation/core';
} from '@react-navigation/native';
import createCompatNavigationProp from './createCompatNavigationProp';
import { CompatNavigationProp } from './types';

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { NavigationProp, ParamListBase } from '@react-navigation/core';
import { NavigationProp, ParamListBase } from '@react-navigation/native';
import useCompatNavigation from './useCompatNavigation';
import { CompatNavigationProp } from './types';

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { useIsFocused } from '@react-navigation/core';
import { useIsFocused } from '@react-navigation/native';
type InjectedProps = {
isFocused: boolean;

View File

@@ -7,7 +7,7 @@ Bottom tab navigator for React Navigation following iOS design guidelines.
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/drawer
yarn add @react-navigation/native @react-navigation/drawer
```
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler), [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).

View File

@@ -50,7 +50,7 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-gesture-handler": "^1.0.0",

View File

@@ -3,7 +3,7 @@ import {
createNavigatorFactory,
useNavigationBuilder,
DefaultNavigatorOptions,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
DrawerNavigationState,
DrawerRouterOptions,

View File

@@ -6,7 +6,7 @@ import {
NavigationProp,
Descriptor,
NavigationHelpers,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { DrawerNavigationState } from '@react-navigation/routers';
import { PanGestureHandler } from 'react-native-gesture-handler';

View File

@@ -1,5 +1,5 @@
import * as React from 'react';
import { CommonActions } from '@react-navigation/core';
import { CommonActions } from '@react-navigation/native';
import {
DrawerActions,
DrawerNavigationState,

View File

@@ -7,7 +7,7 @@ React Navigation integration for [bottom navigation](https://material.io/design/
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/material-bottom-tabs
yarn add @react-navigation/native @react-navigation/material-bottom-tabs
```
Setup `react-native-paper` following the [Getting Started guide](https://callstack.github.io/react-native-paper/getting-started.html).

View File

@@ -49,7 +49,7 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-paper": "^3.0.0",

View File

@@ -3,7 +3,7 @@ import {
useNavigationBuilder,
createNavigatorFactory,
DefaultNavigatorOptions,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
TabRouter,
TabRouterOptions,

View File

@@ -4,7 +4,7 @@ import {
Descriptor,
NavigationProp,
NavigationHelpers,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { TabNavigationState } from '@react-navigation/routers';
export type MaterialBottomTabNavigationEventMap = {

View File

@@ -2,7 +2,7 @@ import * as React from 'react';
import { StyleSheet } from 'react-native';
import { BottomNavigation } from 'react-native-paper';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { TabNavigationState, TabActions } from '@react-navigation/routers';
import {

View File

@@ -7,7 +7,7 @@ React Navigation integration for animated tab view component from [`react-native
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/material-top-tabs react-native-tab-view
yarn add @react-navigation/native @react-navigation/material-top-tabs react-native-tab-view
```
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler) and [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated)..

View File

@@ -49,7 +49,7 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-gesture-handler": "^1.0.0",

View File

@@ -3,7 +3,7 @@ import {
useNavigationBuilder,
createNavigatorFactory,
DefaultNavigatorOptions,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
TabRouter,
TabRouterOptions,

View File

@@ -6,7 +6,7 @@ import {
NavigationHelpers,
Route,
NavigationProp,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { TabNavigationState } from '@react-navigation/routers';
export type MaterialTopTabNavigationEventMap = {

View File

@@ -1,7 +1,7 @@
import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { TabBar } from 'react-native-tab-view';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { MaterialTopTabBarProps } from '../types';

View File

@@ -1,6 +1,6 @@
import * as React from 'react';
import { TabView, SceneRendererProps } from 'react-native-tab-view';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { TabNavigationState, TabActions } from '@react-navigation/routers';
import MaterialTopTabBar from './MaterialTopTabBar';

View File

@@ -9,7 +9,7 @@ Expo is currently not supported as it includes an older version of `react-native
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/native-stack
yarn add @react-navigation/native @react-navigation/native-stack
```
Now we need to install [`react-native-screens`](https://github.com/kmagiera/react-native-screens).

View File

@@ -38,7 +38,7 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-screens": "^2.0.0-alpha.8"

View File

@@ -3,7 +3,7 @@ import {
createNavigatorFactory,
useNavigationBuilder,
EventArg,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
StackRouter,

View File

@@ -6,7 +6,7 @@ import {
NavigationHelpers,
NavigationProp,
ParamListBase,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
StackNavigationState,
StackRouterOptions,

View File

@@ -6,7 +6,7 @@ import {
ScreenStackHeaderRightView,
// eslint-disable-next-line import/no-unresolved
} from 'react-native-screens';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { NativeStackNavigationOptions } from '../types';
type Props = NativeStackNavigationOptions & {

View File

@@ -7,7 +7,7 @@ React Native integration for React Navigation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/native
yarn add @react-navigation/native
```
## Usage

View File

@@ -29,6 +29,9 @@
"prepare": "bob build",
"clean": "del lib"
},
"dependencies": {
"@react-navigation/core": "^5.0.0-alpha.27"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
"@types/react": "^16.9.11",
@@ -39,7 +42,6 @@
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*"
},

View File

@@ -1,3 +1,5 @@
export * from '@react-navigation/core';
export { default as NavigationNativeContainer } from './NavigationNativeContainer';
export { default as useBackButton } from './useBackButton';

View File

@@ -9,7 +9,7 @@ You probably don't need to use this package directly if you're not building cust
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/routers
yarn add @react-navigation/routers
```
## Usage
@@ -17,7 +17,7 @@ yarn add @react-navigation/core @react-navigation/routers
A basic custom navigator bundling a router and a view looks like this:
```js
import { createNavigatorFactory, useNavigationBuilder } from '@react-navigation/core';
import { createNavigatorFactory, useNavigationBuilder } from '@react-navigation/native';
import { StackRouter } from '@react-navigation/routers';
function StackNavigator({ initialRouteName, children, ...rest }) {

View File

@@ -29,6 +29,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/core": "^5.0.0-alpha.27",
"shortid": "^2.2.15"
},
"devDependencies": {
@@ -36,9 +37,6 @@
"del-cli": "^3.0.0",
"typescript": "^3.7.2"
},
"peerDependencies": {
"@react-navigation/core": "^5.0.0-alpha.0"
},
"@react-native-community/bob": {
"source": "src",
"output": "lib",

View File

@@ -7,7 +7,7 @@ Stack navigator for React Navigation.
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core @react-navigation/stack @react-native-community/masked-view
yarn add @react-navigation/native @react-navigation/stack @react-native-community/masked-view
```
Now we need to install [`react-native-gesture-handler`](https://github.com/kmagiera/react-native-gesture-handler), [`react-native-reanimated`](https://github.com/kmagiera/react-native-reanimated), [`react-native-screens`](https://github.com/kmagiera/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).

View File

@@ -51,7 +51,7 @@
},
"peerDependencies": {
"@react-native-community/masked-view": "^0.1.1",
"@react-navigation/core": "^5.0.0-alpha.0",
"@react-navigation/native": "^5.0.0-alpha.0",
"react": "*",
"react-native": "*",
"react-native-gesture-handler": "^1.0.0",

View File

@@ -4,7 +4,7 @@ import {
createNavigatorFactory,
DefaultNavigatorOptions,
EventArg,
} from '@react-navigation/core';
} from '@react-navigation/native';
import {
StackRouter,
StackRouterOptions,

View File

@@ -12,7 +12,7 @@ import {
Descriptor,
Route,
NavigationHelpers,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { StackNavigationState } from '@react-navigation/routers';
export type StackNavigationEventMap = {

View File

@@ -4,7 +4,7 @@ import {
NavigationContext,
Route,
ParamListBase,
} from '@react-navigation/core';
} from '@react-navigation/native';
import { StackNavigationState } from '@react-navigation/routers';
import { EdgeInsets } from 'react-native-safe-area-context';

View File

@@ -8,7 +8,7 @@ import {
} from 'react-native';
import Animated from 'react-native-reanimated';
import { EdgeInsets } from 'react-native-safe-area-context';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import HeaderBackButton from './HeaderBackButton';
import HeaderBackground from './HeaderBackground';
import memoize from '../../utils/memoize';

View File

@@ -2,7 +2,7 @@ import * as React from 'react';
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
import Animated from 'react-native-reanimated';
import { StackNavigationState } from '@react-navigation/routers';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { Props as HeaderContainerProps } from '../Header/HeaderContainer';
import Card from './Card';
import { Scene, Layout, StackHeaderMode, TransitionPreset } from '../../types';

View File

@@ -11,7 +11,7 @@ import Animated from 'react-native-reanimated';
import { EdgeInsets } from 'react-native-safe-area-context';
// eslint-disable-next-line import/no-unresolved
import * as Screens from 'react-native-screens'; // Import with * as to prevent getters being called
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { StackNavigationState } from '@react-navigation/routers';
import { getDefaultHeaderHeight } from '../Header/HeaderSegment';

View File

@@ -1,7 +1,7 @@
import * as React from 'react';
import { Platform } from 'react-native';
import { SafeAreaConsumer, EdgeInsets } from 'react-native-safe-area-context';
import { Route } from '@react-navigation/core';
import { Route } from '@react-navigation/native';
import { StackActions, StackNavigationState } from '@react-navigation/routers';
import CardStack from './CardStack';