我有一个组件(EmailBuilder),该组件使用react上下文api呈现某些内容,我想将其呈现为html,我尝试了以下方法:
import * as React from 'react'
import { EmailBuilder } from './EmailBuilder';
import ReactDOMServer from 'react-dom/server';
export const EmailBuilderPage = (props: any) => {
const element = <EmailBuilder />
return <>
{element}
<br />
<h1>HTML</h1>
{ReactDOMServer.renderToString(element)}
</>
}
虽然呈现了元素的根,但未能呈现上下文api对元素的任何更改。
这完全有可能吗?