Skip to content

Commit f37bf21

Browse files
PiwaiiJustkant
authored andcommittedJun 7, 2017
Update TabBar.js (aksonov#1888)
1 parent 2d13d68 commit f37bf21

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/TabBar.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ class TabBar extends Component {
2020
hideOnChildTabs: PropTypes.bool,
2121
};
2222

23-
static onSelect(el) {
23+
static onSelect(el, selectedSceneKey) {
2424
if (!Actions[el.props.name]) {
2525
throw new Error(
2626
`No action is defined for name=${el.props.name} ` +
2727
`actions: ${JSON.stringify(Object.keys(Actions))}`);
2828
}
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') {
3034
el.props.onPress();
3135
} else {
3236
Actions[el.props.name]();
@@ -61,7 +65,7 @@ class TabBar extends Component {
6165
style={state.tabBarStyle}
6266
selectedIconStyle={state.tabBarSelectedItemStyle}
6367
iconStyle={state.tabBarIconContainerStyle}
64-
onSelect={TabBar.onSelect} {...state}
68+
onSelect={(el) => TabBar.onSelect(el, selected.sceneKey)} {...state}
6569
selected={selected.sceneKey}
6670
pressOpacity={this.props.pressOpacity}
6771
>

0 commit comments

Comments
 (0)