diff --git a/example/src/examples/Test06/ModalGroup.tsx b/example/src/examples/Test06/ModalGroup.tsx index 327dfdf5..93dda30f 100644 --- a/example/src/examples/Test06/ModalGroup.tsx +++ b/example/src/examples/Test06/ModalGroup.tsx @@ -64,7 +64,18 @@ export const ModalGroup = React.forwardRef( setCurrentModalIndex(nextModalIndex); modalRef.setVisibility(true); }} - onPressClosePrevModal={async (modalIndex) => { + onPressCloseModal={async (modalIndex) => { + const modalRef = modalRefs.current[`${modalIndex}`]; + + // guard + if (modalRef == null) { + return; + } + + await modalRef.setVisibility(false); + setCurrentModalIndex(modalIndex - 1); + }} + onPressClosePrevModal={(modalIndex) => { const prevModalIndex = modalIndex - 1; const prevModalRef = modalRefs.current[`${prevModalIndex}`]; @@ -74,8 +85,7 @@ export const ModalGroup = React.forwardRef( return; } - await prevModalRef.setVisibility(false); - setCurrentModalIndex(prevModalIndex); + prevModalRef.setVisibility(false); }} /> diff --git a/example/src/examples/Test06/ModalGroupItemContent.tsx b/example/src/examples/Test06/ModalGroupItemContent.tsx index 52c2f9c5..0398f090 100644 --- a/example/src/examples/Test06/ModalGroupItemContent.tsx +++ b/example/src/examples/Test06/ModalGroupItemContent.tsx @@ -16,6 +16,7 @@ export function ModalGroupItemContent(props: { modalIndex: number; onPressOpenNextModal: (modalIndex: number) => void; onPressClosePrevModal: (modalIndex: number) => void; + onPressCloseModal: (modalIndex: number) => void; }) { const logDisplayRef = React.useRef(null); @@ -82,7 +83,7 @@ export function ModalGroupItemContent(props: { { - modalContext.setVisibility(false); + props.onPressCloseModal(props.modalIndex); }} /> {props.modalIndex > 0 && (