Skip to content

Commit 5c00a06

Browse files
committed
feat: stack based navigation
1 parent 51f4f1f commit 5c00a06

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/screens/details.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export function DetailsScreen({message = "Details Screen"}: DetailsScreenProps)
1111
return (
1212
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
1313
<Text>{message}</Text>
14-
<Button onPress={() => navigation.navigate('Home')}>Go Home</Button>
14+
<Button onPress={() => navigation.push('Details')}>Go Deeper</Button>
15+
<Button onPress={() => navigation.goBack('Details')}>Go Back</Button>
16+
<Button onPress={() => navigation.popTo('Home')}>Go Home</Button>
1517
</View>
1618
);
1719
}

src/screens/home.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
import { useNavigation } from '@react-navigation/native';
12
import { View, Text } from 'react-native';
3+
import { Button } from '@react-navigation/elements';
24

35
export type HomeScreenProps = {
46
message?: string;
57
};
68

79
export function HomeScreen({message = "Home Screen"}: HomeScreenProps) {
10+
const navigation = useNavigation();
11+
812
return (
913
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
1014
<Text>{message}</Text>
15+
<Button onPress={() => navigation.push('Details')}>Go to Details</Button>
1116
</View>
1217
);
1318
}

0 commit comments

Comments
 (0)