A React/Redux app that I develop needs to live inside an iframe. The surrounding document can be told to resize the iframe by sending a message from within. I would like to send the resize message any time the DOM changes.
Using a generic MutationObserver will cause a flickering between the time the DOM is updated and the resizing of the iframe.
The application is set up using
render(
<Provider store={store}>
...
</Provider>,
document.querySelector("..."),
resizeIframe
);
The resizeIframe callback function solves the initial rendering, but does not help with child component updates.
How can I trigger resizeIframe on any React (re)rendering?
Edit: I know resizing on every rendering is inefficient. However, getting rid of the delay between DOM resize and iframe resize appears to be the bigger problem.