From d900c5dfca88b1d2ce0f28ca6ca057c7b5e5870e Mon Sep 17 00:00:00 2001 From: Iacopo Pazzaglia Date: Sat, 27 Jan 2018 21:37:36 +0100 Subject: [PATCH] Allow tabBarTestIDProps to be a function that receive the focused status (#3303) --- packages/react-navigation/src/views/TabView/TabView.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-navigation/src/views/TabView/TabView.js b/packages/react-navigation/src/views/TabView/TabView.js index 82a564b0..b978a1c9 100644 --- a/packages/react-navigation/src/views/TabView/TabView.js +++ b/packages/react-navigation/src/views/TabView/TabView.js @@ -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 }) => {