Skip to content

Commit eb39e6a

Browse files
committed
fix(types): expose Modal native ref prop
1 parent 75e1f06 commit eb39e6a

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/react-native/Libraries/Modal/Modal.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ export interface ModalBaseProps {
5050
* Defaults to `white` if not provided and transparent is `false`. Ignored if `transparent` is `true`.
5151
*/
5252
backdropColor?: ColorValue | undefined;
53+
54+
/**
55+
* A ref to the native Modal component.
56+
*/
57+
modalRef?: React.RefObject<Modal | null> | undefined;
5358
}
5459

5560
export interface ModalPropsIOS {

packages/react-native/types/__typetests__/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
FocusEvent,
4747
GestureResponderEvent,
4848
HostComponent,
49+
HostInstance,
4950
I18nManager,
5051
Image,
5152
ImageBackground,
@@ -1540,6 +1541,10 @@ const KeyboardAvoidingViewTest = () => <KeyboardAvoidingView enabled />;
15401541

15411542
const ModalTest = () => <Modal hardwareAccelerated />;
15421543
const ModalTest2 = () => <Modal hardwareAccelerated testID="modal-test-2" />;
1544+
const ModalRefTest = () => {
1545+
const modalRef = React.useRef<Modal & HostInstance>(null);
1546+
return <Modal modalRef={modalRef} />;
1547+
};
15431548

15441549
// $ExpectType HostComponent<{ nativeProp: string; }>
15451550
const NativeBridgedComponent = requireNativeComponent<{nativeProp: string}>(

0 commit comments

Comments
 (0)