@@ -74,26 +74,27 @@ function TabNavigator({
7474 return (
7575 < NavigationContent>
7676 < View style= {[{ flexDirection: ' row' }, tabBarStyle]}>
77- {state .routes .map ((route ) => (
77+ {state .routes .map ((route , index ) => (
7878 < Pressable
7979 key= {route .key }
8080 onPress= {() => {
81+ const isFocused = state .index === index;
8182 const event = navigation .emit ({
8283 type: ' tabPress' ,
8384 target: route .key ,
8485 canPreventDefault: true ,
8586 });
8687
87- if (! event .defaultPrevented ) {
88+ if (! isFocused && ! event .defaultPrevented ) {
8889 navigation .dispatch ({
89- ... TabActions .jumpTo (route .name ),
90+ ... TabActions .jumpTo (route .name , route . params ),
9091 target: state .key ,
9192 });
9293 }
9394 }}
9495 style= {{ flex: 1 }}
9596 >
96- < Text > {descriptors[route .key ].options .title || route .name }< / Text >
97+ < Text > {descriptors[route .key ].options .title ?? route .name }< / Text >
9798 < / Pressable>
9899 ))}
99100 < / View>
@@ -252,20 +253,21 @@ function TabNavigator({
252253 return (
253254 < NavigationContent>
254255 < View style= {[{ flexDirection: ' row' }, tabBarStyle]}>
255- { state .routes .map ((route ) => (
256+ {state .routes .map ((route , index ) => (
256257 < Pressable
257258 key= {route .key }
258259 onPress= {() => {
260+ const isFocused = state .index === index;
259261 const event = navigation .emit ({
260262 type: ' tabPress' ,
261263 target: route .key ,
262264 canPreventDefault: true ,
263265 data: {
264- isAlreadyFocused: route . key === state . routes [ state . index ]. key ,
266+ isAlreadyFocused: isFocused ,
265267 },
266268 });
267269
268- if (! event .defaultPrevented ) {
270+ if (! isFocused && ! event .defaultPrevented ) {
269271 navigation .dispatch ({
270272 ... CommonActions .navigate (route),
271273 target: state .key ,
@@ -274,7 +276,7 @@ function TabNavigator({
274276 }}
275277 style= {{ flex: 1 }}
276278 >
277- <Text >{ descriptors [route .key ].options .title || route .name } </Text >
279+ < Text > {descriptors[route .key ].options .title ?? route .name }< / Text >
278280 < / Pressable>
279281 ))}
280282 < / View>
0 commit comments