https://stackblitz.com/edit/react-modal-with-transition-out?...
Ok it all makes sense now. I’d forgotten about useLayoutEffect. Haven’t had to write much react recently.