File tree Expand file tree Collapse file tree 3 files changed +8
-24
lines changed Expand file tree Collapse file tree 3 files changed +8
-24
lines changed Original file line number Diff line number Diff line change @@ -45,14 +45,6 @@ class TabView extends React.PureComponent<Props> {
45
45
return route . routeName ;
46
46
} ;
47
47
48
- _getOnPress = ( previousScene , { route } ) => {
49
- const { descriptors } = this . props ;
50
- const descriptor = descriptors [ route . key ] ;
51
- const options = descriptor . options ;
52
-
53
- return options . tabBarOnPress ;
54
- } ;
55
-
56
48
_getTestIDProps = ( { route, focused } ) => {
57
49
const { descriptors } = this . props ;
58
50
const descriptor = descriptors [ route . key ] ;
@@ -107,6 +99,7 @@ class TabView extends React.PureComponent<Props> {
107
99
getLabelText = { this . props . getLabelText }
108
100
getTestIDProps = { this . _getTestIDProps }
109
101
renderIcon = { this . _renderIcon }
102
+ onTabPress = { this . props . onTabPress }
110
103
/>
111
104
) ;
112
105
} ;
Original file line number Diff line number Diff line change @@ -74,23 +74,14 @@ export default function createTabNavigator(TabView: React.ComponentType<*>) {
74
74
const { descriptors } = this . props ;
75
75
const descriptor = descriptors [ route . key ] ;
76
76
const { navigation, options } = descriptor ;
77
+ const focused = navigation . isFocused ( ) ;
77
78
78
79
if ( options . tabBarOnPress ) {
79
- options . tabBarOnPress ( {
80
- navigation,
81
- } ) ;
82
- } else {
83
- const isFocused =
84
- this . props . navigation . state . index ===
85
- this . props . navigation . state . routes . indexOf ( route ) ;
86
-
87
- if ( isFocused ) {
88
- if ( route . hasOwnProperty ( 'index' ) && route . index > 0 ) {
89
- navigation . dispatch ( StackActions . popToTop ( { key : route . key } ) ) ;
90
- } else {
91
- // TODO: do something to scroll to top
92
- }
93
- }
80
+ options . tabBarOnPress ( { navigation } ) ;
81
+ } else if ( focused && route . hasOwnProperty ( 'index' ) && route . index > 0 ) {
82
+ navigation . dispatch ( StackActions . popToTop ( { key : route . key } ) ) ;
83
+ } else if ( focused ) {
84
+ // TODO: do something to scroll to top
94
85
}
95
86
} ;
96
87
Original file line number Diff line number Diff line change @@ -201,8 +201,8 @@ class TabBarBottom extends React.Component<Props> {
201
201
< TouchableWithoutFeedback
202
202
key = { route . key }
203
203
onPress = { ( ) => {
204
- jumpTo ( route . key ) ;
205
204
onTabPress ( { route } ) ;
205
+ jumpTo ( route . key ) ;
206
206
} }
207
207
>
208
208
< View
You can’t perform that action at this time.
0 commit comments