From e611745a2f49de73faa2e6e240a3a5a9d6373796 Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 2 Oct 2023 14:10:33 +0700 Subject: [PATCH 1/2] fix: 28354 --- .../AppNavigator/createCustomStackNavigator/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index b3e108165c02..c4233a3ae8ae 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import {useNavigationBuilder, createNavigatorFactory} from '@react-navigation/native'; import {StackView} from '@react-navigation/stack'; import CustomRouter from './CustomRouter'; +import useWindowDimensions from '../../../../hooks/useWindowDimensions'; const propTypes = { /* Determines if the navigator should render the StackView (narrow) or ThreePaneView (wide) */ @@ -25,16 +26,20 @@ const defaultProps = { }; function ResponsiveStackNavigator(props) { - const isSmallScreenWidthRef = useRef(props.isSmallScreenWidth); + const {isSmallScreenWidth} = useWindowDimensions(); + + const isSmallScreenWidthRef = useRef(isSmallScreenWidth); + + isSmallScreenWidthRef.current = isSmallScreenWidth; + const {navigation, state, descriptors, NavigationContent} = useNavigationBuilder(CustomRouter, { children: props.children, screenOptions: props.screenOptions, initialRouteName: props.initialRouteName, + // Options for useNavigationBuilder won't update on prop change, so we need to pass a getter for the router to have the current state of isSmallScreenWidth. getIsSmallScreenWidth: () => isSmallScreenWidthRef.current, }); - // Options for useNavigationBuilder won't update on prop change, so we need to pass a getter for the router to have the current state of isSmallScreenWidth. - isSmallScreenWidthRef.current = props.isSmallScreenWidth; return ( From b798be2e6d1ce615a76067fd72313ad3f36574ff Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 3 Oct 2023 11:38:56 +0700 Subject: [PATCH 2/2] fix lint --- .../Navigation/AppNavigator/createCustomStackNavigator/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index c4233a3ae8ae..58be3d2af3da 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -40,7 +40,6 @@ function ResponsiveStackNavigator(props) { getIsSmallScreenWidth: () => isSmallScreenWidthRef.current, }); - return (