Allow tabBarTestIDProps to be a function that receive the focused status (#3303)

This commit is contained in:
Iacopo Pazzaglia
2018-01-27 21:37:36 +01:00
parent 4d01c85c78
commit d900c5dfca

View File

@@ -64,13 +64,15 @@ class TabView extends React.PureComponent {
return options.tabBarOnPress;
};
_getTestIDProps = ({ route }) => {
_getTestIDProps = ({ route, focused }) => {
const options = this.props.router.getScreenOptions(
this.props.childNavigationProps[route.key],
this.props.screenProps || {}
);
return options.tabBarTestIDProps;
return typeof options.tabBarTestIDProps === 'function'
? options.tabBarTestIDProps({ focused })
: options.tabBarTestIDProps;
};
_renderIcon = ({ focused, route, tintColor }) => {