Skip to content

Commit 9d13c4d

Browse files
authored
Rework fundamentals to accomodate static API (#1293)
1 parent 4806039 commit 9d13c4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+964
-471
lines changed

sidebars.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

static/examples/7.x/go-back.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Button, View, Text } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation }) {
6+
function HomeScreen() {
7+
const navigation = useNavigation();
8+
79
return (
810
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
911
<Text>Home Screen</Text>
@@ -15,7 +17,9 @@ function HomeScreen({ navigation }) {
1517
);
1618
}
1719

18-
function DetailsScreen({ navigation }) {
20+
function DetailsScreen() {
21+
const navigation = useNavigation();
22+
1923
return (
2024
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
2125
<Text>Details Screen</Text>

static/examples/7.x/multiple-navigate.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Button, View, Text } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation }) {
6+
function HomeScreen() {
7+
const navigation = useNavigation();
8+
79
return (
810
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
911
<Text>Home Screen</Text>
@@ -15,7 +17,9 @@ function HomeScreen({ navigation }) {
1517
);
1618
}
1719

18-
function DetailsScreen({ navigation }) {
20+
function DetailsScreen() {
21+
const navigation = useNavigation();
22+
1923
return (
2024
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
2125
<Text>Details Screen</Text>

static/examples/7.x/multiple-push.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Button, View, Text } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation }) {
6+
function HomeScreen() {
7+
const navigation = useNavigation();
8+
79
return (
810
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
911
<Text>Home Screen</Text>
@@ -15,7 +17,9 @@ function HomeScreen({ navigation }) {
1517
);
1618
}
1719

18-
function DetailsScreen({ navigation }) {
20+
function DetailsScreen() {
21+
const navigation = useNavigation();
22+
1923
return (
2024
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
2125
<Text>Details Screen</Text>

static/examples/7.x/new-screen.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Button, View, Text } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation }) {
6+
function HomeScreen() {
7+
const navigation = useNavigation();
8+
79
return (
810
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
911
<Text>Home Screen</Text>

static/examples/7.x/params-nested-navigators.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as React from 'react';
22
import { Button, View, Text } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55
import { createDrawerNavigator } from '@react-navigation/drawer';
66

7-
function SettingsScreen({ route, navigation }) {
7+
function SettingsScreen({ route }) {
8+
const navigation = useNavigation();
9+
810
const { user } = route.params;
911
return (
1012
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -18,15 +20,19 @@ function SettingsScreen({ route, navigation }) {
1820
);
1921
}
2022

21-
function ProfileScreen({ navigation }) {
23+
function ProfileScreen() {
24+
const navigation = useNavigation();
25+
2226
return (
2327
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
2428
<Text>Profile Screen</Text>
2529
</View>
2630
);
2731
}
2832

29-
function HomeScreen({ navigation }) {
33+
function HomeScreen() {
34+
const navigation = useNavigation();
35+
3036
return (
3137
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
3238
<Text>Home Screen</Text>

static/examples/7.x/passing-params-back.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Text, TextInput, View, Button } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation, route }) {
6+
function HomeScreen({ route }) {
7+
const navigation = useNavigation();
8+
79
React.useEffect(() => {
810
if (route.params?.post) {
911
// Post updated, do something with `route.params.post`
@@ -22,7 +24,8 @@ function HomeScreen({ navigation, route }) {
2224
);
2325
}
2426

25-
function CreatePostScreen({ navigation, route }) {
27+
function CreatePostScreen({ route }) {
28+
const navigation = useNavigation();
2629
const [postText, setPostText] = React.useState('');
2730

2831
return (

static/examples/7.x/passing-params.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Text, View, Button } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation }) {
6+
function HomeScreen() {
7+
const navigation = useNavigation();
8+
79
return (
810
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
911
<Text>Home Screen</Text>
@@ -21,7 +23,9 @@ function HomeScreen({ navigation }) {
2123
);
2224
}
2325

24-
function DetailsScreen({ route, navigation }) {
26+
function DetailsScreen({ route }) {
27+
const navigation = useNavigation();
28+
2529
/* 2. Get the param */
2630
const { itemId } = route.params;
2731
const { otherParam } = route.params;

static/examples/7.x/pop-to-top.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import * as React from 'react';
22
import { Button, View, Text } from 'react-native';
3-
import { NavigationContainer } from '@react-navigation/native';
3+
import { NavigationContainer, useNavigation } from '@react-navigation/native';
44
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
function HomeScreen({ navigation }) {
6+
function HomeScreen() {
7+
const navigation = useNavigation();
8+
79
return (
810
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
911
<Text>Home Screen</Text>
@@ -15,7 +17,9 @@ function HomeScreen({ navigation }) {
1517
);
1618
}
1719

18-
function DetailsScreen({ navigation }) {
20+
function DetailsScreen() {
21+
const navigation = useNavigation();
22+
1923
return (
2024
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
2125
<Text>Details Screen</Text>

versioned_docs/version-7.x/bottom-tab-navigator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The `Tab.Navigator` component accepts following props:
5353

5454
#### `id`
5555

56-
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-prop.md#getparent) to refer to this navigator in a child navigator.
56+
Optional unique ID for the navigator. This can be used with [`navigation.getParent`](navigation-object.md#getparent) to refer to this navigator in a child navigator.
5757

5858
#### `initialRouteName`
5959

@@ -442,7 +442,7 @@ React.useEffect(() => {
442442

443443
### Helpers
444444

445-
The tab navigator adds the following methods to the navigation prop:
445+
The tab navigator adds the following methods to the navigation object:
446446

447447
#### `jumpTo`
448448

0 commit comments

Comments
 (0)