# How do I dismiss a modal w/ correct types in TypeScript & React?

**URL:** <https://forum.ionicframework.com/t/how-do-i-dismiss-a-modal-w-correct-types-in-typescript-react/237229>\
**Category:** Ionic Framework\
**Created:** [October 25, 2023, 7:56am UTC](https://forum.ionicframework.com/t/how-do-i-dismiss-a-modal-w-correct-types-in-typescript-react/237229 "2023-10-25T07:56:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![innerpug](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/innerpug/32/145429_2.png) [@innerpug](https://forum.ionicframework.com/u/innerpug)\
**Post date:** [October 25, 2023, 7:56am UTC](https://forum.ionicframework.com/t/how-do-i-dismiss-a-modal-w-correct-types-in-typescript-react/237229/1 "2023-10-25T07:56:00Z")

</div>

I tried to use the example code provided here [ion-modal: Ionic Mobile App Custom Modal API Component](https://ionicframework.com/docs/api/modal) but `HTMLIonModalElement` is not defined.

If I omit `HTMLIonModalElement` and just write `const modal = useRef(null);` then I get no `dismiss` method on `modal.current`.

Please advice how I can call `modal.current.dismiss` with the correct types. 🙏

This was reported as a GitHub issue [Not able to import HTMLIonModalElement - ionic v4 · Issue #17809 · ionic-team/ionic-framework · GitHub](https://github.com/ionic-team/ionic-framework/issues/17809), but a contributor there said the question should be asked here.
