Skip to content

Commit f410ae4

Browse files
authored
Merge pull request Expensify#79344 from software-mansion-labs/swrhp/add-optional-chaining
[CP Staging] Add optional chaining to getRootState in show wide rhp hooks
2 parents f302565 + 03349b9 commit f410ae4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

  • src/components/WideRHPContextProvider

src/components/WideRHPContextProvider/useShowSuperWideRHPVersion/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function useShowSuperWideRHPVersion(condition: boolean) {
2828
removeWideRHPRouteKey(route);
2929
removeSuperWideRHPRouteKey(route);
3030
// When the RHP has been closed, expandedRHPProgress should be set to 0.
31-
if (navigationRef.getRootState().routes.at(-1)?.name !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
31+
if (navigationRef?.getRootState()?.routes?.at(-1)?.name !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
3232
expandedRHPProgress.setValue(0);
3333
}
3434
}, [removeSuperWideRHPRouteKey, removeWideRHPRouteKey, route]);

src/components/WideRHPContextProvider/useShowWideRHPVersion/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function useShowWideRHPVersion(condition: boolean) {
1919
const onWideRHPClose = useCallback(() => {
2020
removeWideRHPRouteKey(route);
2121
// When the RHP has been closed, expandedRHPProgress should be set to 0.
22-
if (navigationRef.getRootState().routes.at(-1)?.name !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
22+
if (navigationRef?.getRootState()?.routes?.at(-1)?.name !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
2323
expandedRHPProgress.setValue(0);
2424
}
2525
}, [removeWideRHPRouteKey, route]);

0 commit comments

Comments
 (0)