mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
react-modal: add portal instance property (#40714)
* `react-modal`: add `portal` instance property * Improve example
This commit is contained in:
Vendored
+5
@@ -126,4 +126,9 @@ declare class ReactModal extends React.Component<ReactModal.Props> {
|
||||
* and other assistive technologies while the modal is open.
|
||||
*/
|
||||
static setAppElement(appElement: string | HTMLElement): void;
|
||||
|
||||
portal: {
|
||||
overlay: Element | undefined;
|
||||
content: HTMLDivElement;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,3 +82,13 @@ class ExampleOfUsingReactModal extends React.Component {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MyWrapperComponent: React.FC = () => {
|
||||
const reactModaRef = React.useRef<ReactModal>();
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
reactModaRef.current.portal.content.focus();
|
||||
});
|
||||
|
||||
return <ReactModal isOpen ref={reactModaRef}>Hello, World!</ReactModal>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user