Use the renderToStaticMarkup
method. As per the documentation:
You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
const htmlString = ReactDOMServer.renderToStaticMarkup(
<div>
...
</div>
);