-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
react.page.tsx
38 lines (34 loc) · 1.08 KB
/
react.page.tsx
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
27
28
29
30
31
32
33
34
35
36
37
38
import React from "https://esm.sh/react";
import { Container } from "../container.ts";
import { Request } from "../mod.ts";
export const options = {
// Define custom html template
template: "react.template.html",
// Define html title
title: "React SSR",
};
// Define react props: https://reactjs.org/docs/components-and-props.html
export const props = async function (request: Request) {
const container: Container = request.container;
return {
params: request.getParams(),
header: "Click me!",
repository: await container.repository,
};
};
// Define component: https://reactjs.org/docs/components-and-props.html
const App = (props: { params: string[]; header: string }) => {
const [count, setCount] = React.useState(0);
return (
<div>
<h2>{props.header}</h2>
<p>
This page was created using Deno, Fastro and React's server-side
rendering (SSR). Click to try the react hook.
</p>
<button onClick={() => setCount(count + 1)}>Click me</button>
<p>You clicked me {count} times</p>
</div>
);
};
export default App;