Skip to content

Commit db74dc6

Browse files
code formatting
1 parent a1b395f commit db74dc6

File tree

1 file changed

+100
-111
lines changed

1 file changed

+100
-111
lines changed

versioned_docs/version-7.x/navigation-object.md

Lines changed: 100 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,14 @@ function HomeScreen() {
9393
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
9494
<Text>This is the home screen of the app</Text>
9595
<Button
96-
onPress={
97-
() =>
98-
// highlight-start
99-
navigation.navigate('Profile', {
100-
names: ['Brent', 'Satya', 'Michaś'],
101-
})
96+
onPress={() => {
97+
// highlight-start
98+
navigation.navigate('Profile', {
99+
names: ['Brent', 'Satya', 'Michaś'],
100+
});
102101
// highlight-end
103-
}
102+
}}
104103
>
105-
{' '}
106104
Go to Brent's profile
107105
</Button>
108106
</View>
@@ -120,7 +118,7 @@ function ProfileScreen({ route }) {
120118
<Text>{route.params.names[0]}</Text>
121119
<Text>{route.params.names[1]}</Text>
122120
<Text>{route.params.names[2]}</Text>
123-
<Button onPress={() => navigation.goBack()}>Go back </Button>
121+
<Button onPress={() => navigation.goBack()}>Go back</Button>
124122
</View>
125123
);
126124
}
@@ -158,14 +156,12 @@ function HomeScreen({ navigation: { navigate } }) {
158156
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
159157
<Text>This is the home screen of the app</Text>
160158
<Button
161-
onPress={
162-
() =>
163-
// highlight-start
164-
navigate('Profile', { names: ['Brent', 'Satya', 'Michaś'] })
159+
onPress={() => {
160+
// highlight-start
161+
navigate('Profile', { names: ['Brent', 'Satya', 'Michaś'] });
165162
// highlight-end
166-
}
163+
}}
167164
>
168-
{' '}
169165
Go to Brent's profile
170166
</Button>
171167
</View>
@@ -270,13 +266,12 @@ function HomeScreen() {
270266
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
271267
<Text>This is the home screen of the app</Text>
272268
<Button
273-
onPress={() =>
269+
onPress={() => {
274270
navigation.navigate('Profile', {
275271
names: ['Brent', 'Satya', 'Michaś'],
276-
})
277-
}
272+
});
273+
}}
278274
>
279-
{' '}
280275
Go to Brent's profile
281276
</Button>
282277
</View>
@@ -295,7 +290,7 @@ function ProfileScreen({ route }) {
295290
<Text>{route.params.names[1]}</Text>
296291
<Text>{route.params.names[2]}</Text>
297292
// highlight-next-line
298-
<Button onPress={() => navigation.goBack()}>Go back </Button>
293+
<Button onPress={() => navigation.goBack()}>Go back</Button>
299294
</View>
300295
);
301296
}
@@ -333,11 +328,10 @@ function HomeScreen({ navigation: { navigate } }) {
333328
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
334329
<Text>This is the home screen of the app</Text>
335330
<Button
336-
onPress={() =>
337-
navigate('Profile', { names: ['Brent', 'Satya', 'Michaś'] })
338-
}
331+
onPress={() => {
332+
navigate('Profile', { names: ['Brent', 'Satya', 'Michaś'] });
333+
}}
339334
>
340-
{' '}
341335
Go to Brent's profile
342336
</Button>
343337
</View>
@@ -354,7 +348,7 @@ function ProfileScreen({ navigation, route }) {
354348
<Text>{route.params.names[1]}</Text>
355349
<Text>{route.params.names[2]}</Text>
356350
// highlight-next-line
357-
<Button onPress={() => navigation.goBack()}>Go back </Button>
351+
<Button onPress={() => navigation.goBack()}>Go back</Button>
358352
</View>
359353
);
360354
}
@@ -403,13 +397,13 @@ function HomeScreen() {
403397
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
404398
<Text>This is the home screen of the app</Text>
405399
<Button
406-
onPress={() =>
400+
onPress={() => {
407401
navigation.navigate('Profile', {
408402
names: ['Brent', 'Satya', 'Michaś'],
409-
})
410-
}
403+
});
404+
}}
411405
>
412-
Go to Brents profile{' '}
406+
Go to Brents profile
413407
</Button>
414408
</View>
415409
);
@@ -427,31 +421,30 @@ function ProfileScreen({ route }) {
427421
<Text>{route.params.names[2]}</Text>
428422
<Button onPress={() => navigation.goBack()}>Go back</Button>
429423
<Button
430-
onPress={() =>
424+
onPress={() => {
431425
navigation.replace('Settings', {
432426
someParam: 'Param',
433-
})
434-
}
427+
});
428+
}}
435429
>
436430
Replace this screen with Settings
437431
</Button>
438432
<Button
439-
onPress={
440-
() =>
441-
// codeblock-focus-start
442-
navigation.reset({
443-
index: 0,
444-
routes: [
445-
{
446-
name: 'Settings',
447-
params: { someParam: 'Param1' },
448-
},
449-
],
450-
})
433+
onPress={() => {
434+
// codeblock-focus-start
435+
navigation.reset({
436+
index: 0,
437+
routes: [
438+
{
439+
name: 'Settings',
440+
params: { someParam: 'Param1' },
441+
},
442+
],
443+
});
451444
// codeblock-focus-end
452-
}
445+
}}
453446
>
454-
Reset navigator state to Settings{' '}
447+
Reset navigator state to Settings
455448
</Button>
456449
<Button onPress={() => navigation.navigate('Home')}> Go to Home </Button>
457450
<Button
@@ -470,13 +463,13 @@ function SettingsScreen({ route }) {
470463
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
471464
<Text>Settings screen</Text>
472465
<Text>{route.params.someParam}</Text>
473-
<Button onPress={() => navigation.goBack()}> Go back </Button>
466+
<Button onPress={() => navigation.goBack()}>Go back</Button>
474467
<Button
475-
onPress={() =>
468+
onPress={() => {
476469
navigation.navigate('Profile', {
477470
names: ['Brent', 'Satya', 'Michaś'],
478-
})
479-
}
471+
});
472+
}}
480473
>
481474
Go to Brents profile
482475
</Button>
@@ -517,11 +510,11 @@ function HomeScreen({ navigation: { navigate } }) {
517510
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
518511
<Text>This is the home screen of the app</Text>
519512
<Button
520-
onPress={() =>
521-
navigate('Profile', { names: ['Brent', 'Satya', 'Michaś'] })
522-
}
513+
onPress={() => {
514+
navigate('Profile', { names: ['Brent', 'Satya', 'Michaś'] });
515+
}}
523516
>
524-
Go to Brents profile{' '}
517+
Go to Brents profile
525518
</Button>
526519
</View>
527520
);
@@ -546,22 +539,21 @@ function ProfileScreen({ navigation, route }) {
546539
Replace this screen with Settings
547540
</Button>
548541
<Button
549-
onPress={
550-
() =>
551-
// codeblock-focus-start
552-
navigation.reset({
553-
index: 0,
554-
routes: [
555-
{
556-
name: 'Settings',
557-
params: { someParam: 'Param1' },
558-
},
559-
],
560-
})
542+
onPress={() => {
543+
// codeblock-focus-start
544+
navigation.reset({
545+
index: 0,
546+
routes: [
547+
{
548+
name: 'Settings',
549+
params: { someParam: 'Param1' },
550+
},
551+
],
552+
});
561553
// codeblock-focus-end
562-
}
554+
}}
563555
>
564-
Reset navigator state to Settings{' '}
556+
Reset navigator state to Settings
565557
</Button>
566558
<Button onPress={() => navigation.navigate('Home')}> Go to Home </Button>
567559
<Button
@@ -579,16 +571,15 @@ function SettingsScreen({ navigation, route }) {
579571
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
580572
<Text>Settings screen</Text>
581573
<Text>{route.params.someParam}</Text>
582-
<Button onPress={() => navigation.goBack()}> Go back </Button>
574+
<Button onPress={() => navigation.goBack()}>Go back</Button>
583575
<Button
584-
onPress={() =>
576+
onPress={() => {
585577
navigation.navigate('Profile', {
586578
names: ['Brent', 'Satya', 'Michaś'],
587-
})
588-
}
579+
});
580+
}}
589581
>
590-
{' '}
591-
Go to Brents profile{' '}
582+
Go to Brents profile
592583
</Button>
593584
</View>
594585
);
@@ -646,12 +637,12 @@ function HomeScreen() {
646637
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
647638
<Text>This is the home screen of the app</Text>
648639
<Button
649-
onPress={() =>
640+
onPress={() => {
650641
navigation.navigate('Profile', {
651642
friends: ['Brent', 'Satya', 'Michaś'],
652643
title: "Brent's Profile",
653-
})
654-
}
644+
});
645+
}}
655646
>
656647
Go to Brents profile
657648
</Button>
@@ -671,21 +662,20 @@ function ProfileScreen({ route }) {
671662
<Text>{route.params.friends[1]}</Text>
672663
<Text>{route.params.friends[2]}</Text>
673664
<Button
674-
onPress={
675-
() =>
676-
// highlight-start
677-
navigation.setParams({
678-
friends:
679-
route.params.friends[0] === 'Brent'
680-
? ['Wojciech', 'Szymon', 'Jakub']
681-
: ['Brent', 'Satya', 'Michaś'],
682-
title:
683-
route.params.title === "Brent's Profile"
684-
? "Lucy's Profile"
685-
: "Brent's Profile",
686-
})
665+
onPress={() => {
666+
// highlight-start
667+
navigation.setParams({
668+
friends:
669+
route.params.friends[0] === 'Brent'
670+
? ['Wojciech', 'Szymon', 'Jakub']
671+
: ['Brent', 'Satya', 'Michaś'],
672+
title:
673+
route.params.title === "Brent's Profile"
674+
? "Lucy's Profile"
675+
: "Brent's Profile",
676+
});
687677
// highlight-end
688-
}
678+
}}
689679
>
690680
Swap title and friends
691681
</Button>
@@ -730,12 +720,12 @@ function HomeScreen({ navigation: { navigate } }) {
730720
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
731721
<Text>This is the home screen of the app</Text>
732722
<Button
733-
onPress={() =>
723+
onPress={() => {
734724
navigate('Profile', {
735725
friends: ['Brent', 'Satya', 'Michaś'],
736726
title: "Brent's Profile",
737-
})
738-
}
727+
});
728+
}}
739729
>
740730
Go to Brents profile
741731
</Button>
@@ -753,21 +743,20 @@ function ProfileScreen({ navigation, route }) {
753743
<Text>{route.params.friends[1]}</Text>
754744
<Text>{route.params.friends[2]}</Text>
755745
<Button
756-
onPress={
757-
() =>
758-
// highlight-start
759-
navigation.setParams({
760-
friends:
761-
route.params.friends[0] === 'Brent'
762-
? ['Wojciech', 'Szymon', 'Jakub']
763-
: ['Brent', 'Satya', 'Michaś'],
764-
title:
765-
route.params.title === "Brent's Profile"
766-
? "Lucy's Profile"
767-
: "Brent's Profile",
768-
})
746+
onPress={() => {
747+
// highlight-start
748+
navigation.setParams({
749+
friends:
750+
route.params.friends[0] === 'Brent'
751+
? ['Wojciech', 'Szymon', 'Jakub']
752+
: ['Brent', 'Satya', 'Michaś'],
753+
title:
754+
route.params.title === "Brent's Profile"
755+
? "Lucy's Profile"
756+
: "Brent's Profile",
757+
});
769758
// highlight-end
770-
}
759+
}}
771760
>
772761
Swap title and friends
773762
</Button>
@@ -824,9 +813,9 @@ function HomeScreen() {
824813
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
825814
<Text>This is the home screen of the app</Text>
826815
<Button
827-
onPress={() =>
828-
navigation.navigate('Profile', { title: "Brent's profile" })
829-
}
816+
onPress={() => {
817+
navigation.navigate('Profile', { title: "Brent's profile" });
818+
}}
830819
>
831820
Go to Profile
832821
</Button>

0 commit comments

Comments
 (0)