ReactJS – How to get an Iframe element once it loads?

  html, iframe, javascript, next.js, reactjs

In react application, I am calling a payment form which is depends on third party plugin.
Here I am just appending a .form({..}) and using it. Rest of the things will taken care from their end.

I want to add my own custom methods for onSubmit of form which is loaded via Iframe.

Right now I am getting null for document.getElementById('payment-form'). Once form gets load, If I try it in console manually then will get an Iframe element.

Is it possible to get an onSubmit function which is inside an Iframe and can we modify it?

Please help me to solve this issue.

Source: Ask Javascript Questions