How to set iframe content of a react component

I am trying to set the content of an iframe in a React component but I am not able to do it. I have a component that contains a function which has to be called when the iframe finishes loading. In that function I am setting the content but it doesn’t seem like the onload function is called at all. I am testing it in the Chrome browser. I am trying the following: