From c9c825bee61426635a28ee149eeeff3d628171cd Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Sat, 25 Apr 2020 21:46:57 +0200 Subject: [PATCH] fix: add config to enable redux devtools integration --- example/src/index.tsx | 3 +++ packages/core/src/BaseNavigationContainer.tsx | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/example/src/index.tsx b/example/src/index.tsx index 0a5e691a..66f7ee39 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -60,6 +60,9 @@ YellowBox.ignoreWarnings(['Require cycle:', 'Warning: Async Storage']); enableScreens(); +// @ts-ignore +global.REACT_NAVIGATION_REDUX_DEVTOOLS_EXTENSION_INTEGRATION_ENABLED = true; + type RootDrawerParamList = { Root: undefined; Another: undefined; diff --git a/packages/core/src/BaseNavigationContainer.tsx b/packages/core/src/BaseNavigationContainer.tsx index 3f8b8c16..3edd61fd 100644 --- a/packages/core/src/BaseNavigationContainer.tsx +++ b/packages/core/src/BaseNavigationContainer.tsx @@ -21,6 +21,9 @@ import { NavigationContainerRef, NavigationContainerProps } from './types'; type State = NavigationState | PartialState | undefined; +const DEVTOOLS_CONFIG_KEY = + 'REACT_NAVIGATION_REDUX_DEVTOOLS_EXTENSION_INTEGRATION_ENABLED'; + const MISSING_CONTEXT_ERROR = "Couldn't find a navigation context. Have you wrapped your app with 'NavigationContainer'? See https://reactnavigation.org/docs/getting-started for setup instructions."; @@ -143,7 +146,9 @@ const BaseNavigationContainer = React.forwardRef( ); const { trackState, trackAction } = useDevTools({ - enabled: false, + enabled: + // @ts-ignore + DEVTOOLS_CONFIG_KEY in global ? global[DEVTOOLS_CONFIG_KEY] : false, name: '@react-navigation', reset, state,