From 0915c0572ac8120715865bf0b647440c8a2f4fda Mon Sep 17 00:00:00 2001 From: Maxime Florent Fankam Date: Fri, 9 Feb 2018 23:04:17 +0100 Subject: [PATCH] Allow swipeEnabled be a function (#3378) * Allow swipeEnabled be a function with state param --- packages/react-navigation/src/views/TabView/TabView.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-navigation/src/views/TabView/TabView.js b/packages/react-navigation/src/views/TabView/TabView.js index 1ee5d42d..f5dd5a84 100644 --- a/packages/react-navigation/src/views/TabView/TabView.js +++ b/packages/react-navigation/src/views/TabView/TabView.js @@ -140,11 +140,15 @@ class TabView extends React.PureComponent { const tabBarVisible = options.tabBarVisible == null ? true : options.tabBarVisible; - const swipeEnabled = + let swipeEnabled = options.swipeEnabled == null ? this.props.swipeEnabled : options.swipeEnabled; + if (typeof swipeEnabled === 'function') { + swipeEnabled = swipeEnabled(state); + } + if (tabBarComponent !== undefined && tabBarVisible) { if (tabBarPosition === 'bottom') { renderFooter = this._renderTabBar;