Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 31503 Report gets blank after resizing #32422

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {StackRouter} from '@react-navigation/native';
import lodashFindLast from 'lodash/findLast';
import _ from 'underscore';
import getIsSmallScreenWidth from '@libs/getIsSmallScreenWidth';
import NAVIGATORS from '@src/NAVIGATORS';
import SCREENS from '@src/SCREENS';

Expand Down Expand Up @@ -68,8 +69,9 @@ function CustomRouter(options) {
return {
...stackRouter,
getRehydratedState(partialState, {routeNames, routeParamList}) {
const isSmallScreenWidth = getIsSmallScreenWidth();
// Make sure that there is at least one CentralPaneNavigator (ReportScreen by default) in the state if this is a wide layout
if (!isAtLeastOneCentralPaneNavigatorInState(partialState) && !options.getIsSmallScreenWidth()) {
if (!isAtLeastOneCentralPaneNavigatorInState(partialState) && !isSmallScreenWidth) {
// If we added a route we need to make sure that the state.stale is true to generate new key for this route
// eslint-disable-next-line no-param-reassign
partialState.stale = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ function ResponsiveStackNavigator(props) {
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,
});

const stateToRender = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ function ResponsiveStackNavigator(props) {
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,
});

return (
Expand Down
6 changes: 6 additions & 0 deletions src/libs/getIsSmallScreenWidth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {Dimensions} from 'react-native';
import variables from '@styles/variables';

export default function getIsSmallScreenWidth(windowWidth = Dimensions.get('window').width) {
return windowWidth <= variables.mobileResponsiveWidthBreakpoint;
}
Loading