import { renderToString } from "npm:react-dom/server";
function HelloWorld() {
return (
<h1 className="text-3xl font-bold underline">
Hello world! Cleaned up, w/ props
</h1>
);
}
function Html({ content }) {
return (
<>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<main>
{content}
</main>
</body>
</>
);
}
function reactExample(request: Request) {
const renderedString = renderToString(<Html content={<HelloWorld />} />);
const response = new Response(renderedString, {
headers: {
"Content-Type": "text/html",
},
});
return response;
}
export default reactExample;