Initially, inside a React application, I retrieved HTML file from server as a string and passed it to the iframe's srcDoc to display HTML inside a webpage which is fine. But now, I've been trying to parse that string (using new DOMParser()), store it in a variable and add it as a child of , but this error pops up "Objects are not valid as a React child (found: [object HTMLDocument])". Could you please explain the concept behind rendering raw HTML code inside JSX or the workaround for this problem?
setFile(new DOMParser().parseFromString(res.data, 'text/html'))
...
...
return render ? (
<iframe width='800' height='800'>
{file}
</iframe>
): null