diff --git a/src/components/withNavigationFallback.js b/src/components/withNavigationFallback.js index d5067d7598b0..e82946c9e049 100644 --- a/src/components/withNavigationFallback.js +++ b/src/components/withNavigationFallback.js @@ -1,4 +1,4 @@ -import React, {forwardRef, useContext} from 'react'; +import React, {forwardRef, useContext, useMemo} from 'react'; import {NavigationContext} from '@react-navigation/core'; import getComponentDisplayName from '../libs/getComponentDisplayName'; import refPropTypes from './refPropTypes'; @@ -7,26 +7,22 @@ export default function (WrappedComponent) { function WithNavigationFallback(props) { const context = useContext(NavigationContext); - return !context ? ( - true, - addListener: () => () => {}, - removeListener: () => () => {}, - }} - > + const navigationContextValue = useMemo(() => ({isFocused: () => true, addListener: () => () => {}, removeListener: () => () => {}}), []); + + return context ? ( + + ) : ( + - ) : ( - ); } WithNavigationFallback.displayName = `WithNavigationFocusWithFallback(${getComponentDisplayName(WrappedComponent)})`;