1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/** @jsxImportSource https://esm.sh/preact */
import ImportCar from "https://esm.town/v/tfayyaz/reactImportCar";
import { render } from "npm:preact-render-to-string";
function Car(props) {
return <h2>Hi, I am a {props.color} component Car!</h2>;
}
function Garage() {
return (
<>
<h1>Who lives in my Garage?</h1>
<ImportCar />
<Car color="red" />
<h1>Who else?</h1>
<Car color="blue" />
</>
);
}
export const preactExample = (request: Request) =>
new Response(render(<Garage />), {
headers: {
"Content-Type": "text/html",
},
});