Skip to content

Ref API

The modal takes a ref with two methods, open() and close(). They run the same animations as a change of visible, and do nothing while the modal is already open (or closed) or still animating.

They are for a modal that owns its lifetime — mounted with visible from the start, for instance by a navigator or a modal manager, and closing itself with its animation before it is unmounted:

import { useRef } from 'react';
import { Button } from 'react-native';
import { Modal, type ModalRef } from 'react-native-reanimated-modal';
function ConfirmModal({ onDismiss }: { onDismiss: () => void }) {
const modal = useRef<ModalRef>(null);
return (
<Modal ref={modal} visible onHide={onDismiss}>
<Button title="Done" onPress={() => modal.current?.close()} />
</Modal>
);
}
Method Does
open() Shows the modal with its animation; nothing if it is open or animating
close() Hides it with its animation, then calls onHide; nothing if it is closed or animating

For a modal you show and hide from its parent, visible is all you need — the methods add nothing there.