When iframe contentWindow is null in React
iframe.contentWindow.postMessage(msg, '*');
When you try to do the above but iframe.contentWindow is null,
you can use useEffect as shown below. This is because you need to access the iframe after rendering is finished.
useEffect(() => {
setSumerian(document.getElementById('sumerianHost'));
console.log('ready to start')
}, [])
20211024
Leave a comment