Get modal height async

I need the modal height after creating it dynamically, but get it only after a few milisecs as document.querySelector(’<name of modal-selector’>).clientHeight.

What can I do?

Solved it with ResizeObserver
https://www.npmjs.com/package/resize-observer