Skip to content

Commit

Permalink
refactor: updated modal ref calls to use optional chaining (#699)(by @…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgertig committed Oct 17, 2021
1 parent fdf461b commit ea19e3f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const BottomSheetModalProviderWrapper = ({
!currentMountedSheet.willUnmount &&
stackBehavior === MODAL_STACK_BEHAVIOR.replace
) {
currentMountedSheet.ref.current.minimize();
currentMountedSheet.ref?.current?.minimize();
}

/**
Expand Down Expand Up @@ -105,7 +105,7 @@ const BottomSheetModalProviderWrapper = ({
) {
sheetsQueueRef.current[
sheetsQueueRef.current.length - 1
].ref.current.restore();
].ref?.current?.restore();
}
}, []);
const handleWillUnmountSheet = useCallback((key: string) => {
Expand All @@ -127,7 +127,7 @@ const BottomSheetModalProviderWrapper = ({
*/
const hasMinimizedSheet = _sheetsQueue.length > 1;
if (sheetOnTop && hasMinimizedSheet) {
_sheetsQueue[_sheetsQueue.length - 2].ref.current.restore();
_sheetsQueue[_sheetsQueue.length - 2].ref?.current?.restore();
}

sheetsQueueRef.current = _sheetsQueue;
Expand All @@ -140,14 +140,14 @@ const BottomSheetModalProviderWrapper = ({
? sheetsQueueRef.current.find(item => item.key === key)
: sheetsQueueRef.current[sheetsQueueRef.current.length - 1];
if (sheetToBeDismissed) {
sheetToBeDismissed.ref.current.dismiss();
sheetToBeDismissed.ref?.current?.dismiss();
return true;
}
return false;
}, []);
const handleDismissAll = useCallback(() => {
sheetsQueueRef.current.map(item => {
item.ref.current.dismiss();
item.ref?.current?.dismiss();
});
}, []);
//#endregion
Expand Down

0 comments on commit ea19e3f

Please sign in to comment.