File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,17 @@ class TabBar extends Component {
20
20
hideOnChildTabs : PropTypes . bool ,
21
21
} ;
22
22
23
- static onSelect ( el ) {
23
+ static onSelect ( el , selectedSceneKey ) {
24
24
if ( ! Actions [ el . props . name ] ) {
25
25
throw new Error (
26
26
`No action is defined for name=${ el . props . name } ` +
27
27
`actions: ${ JSON . stringify ( Object . keys ( Actions ) ) } ` ) ;
28
28
}
29
- if ( typeof el . props . onPress === 'function' ) {
29
+ const active = selectedSceneKey == ( el . props . name || el . key )
30
+ if ( active && typeof el . props . onActivePress === 'function' ) {
31
+ el . props . onActivePress ( ) ;
32
+ }
33
+ else if ( typeof el . props . onPress === 'function' ) {
30
34
el . props . onPress ( ) ;
31
35
} else {
32
36
Actions [ el . props . name ] ( ) ;
@@ -61,7 +65,7 @@ class TabBar extends Component {
61
65
style = { state . tabBarStyle }
62
66
selectedIconStyle = { state . tabBarSelectedItemStyle }
63
67
iconStyle = { state . tabBarIconContainerStyle }
64
- onSelect = { TabBar . onSelect } { ...state }
68
+ onSelect = { ( el ) => TabBar . onSelect ( el , selected . sceneKey ) } { ...state }
65
69
selected = { selected . sceneKey }
66
70
pressOpacity = { this . props . pressOpacity }
67
71
>
You can’t perform that action at this time.
0 commit comments