Skip to content

Commit 89d80b2

Browse files
committed
refactor: move press handlers into functions
1 parent 6cf858a commit 89d80b2

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/screens/about.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { View, Text, StyleSheet } from 'react-native';
33
import { Button } from '@react-navigation/elements';
44

55
export type AboutScreenProps = {
6-
depth: number;
76
};
87

98
export function AboutScreen() {
109
const navigation = useNavigation();
11-
const route = useRoute();
1210

13-
const { depth } = route.params as AboutScreenProps;
11+
const handleGoHome = () => {
12+
navigation.popTo('Home');
13+
};
1414

1515
return (
1616
<>
@@ -20,7 +20,7 @@ export function AboutScreen() {
2020
<Text>© 2025 ACME Industries LTD</Text>
2121
</View>
2222
<View style={styles.footer}>
23-
<Button onPress={() => navigation.popTo('Home')}>Back</Button>
23+
<Button onPress={handleGoHome}>Home</Button>
2424
</View>
2525
</>
2626
);

src/screens/home.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ export function HomeScreen() {
1111
const route = useRoute();
1212

1313
const { message } = route.params as HomeScreenProps;
14+
15+
const handleGoToAbout = () => {
16+
navigation.navigate('About');
17+
};
1418

1519
return (
1620
<>
1721
<View style={styles.container}>
1822
<Text>{message}</Text>
1923
</View>
2024
<View style={styles.footer}>
21-
<Button onPress={() => navigation.push('About')}>About</Button>
25+
<Button onPress={handleGoToAbout}>About</Button>
2226
</View>
2327
</>
2428
);

0 commit comments

Comments
 (0)