Files
sweet/example/pages/index.tsx
T
Luca Casonato 56baffa96d feat: support suspending during SSR and useData (#27)
This commit adds support for suspending during JIT SSR rendering.
Additionally this PR adds `useData` support. This hook is triggered
during JIT render and can be used to fetch data. This data is sent to
the client and returned there from calls to useData too.
2021-06-11 13:59:55 +02:00

34 lines
681 B
TypeScript

import { h, IS_BROWSER, useState } from "../deps.ts";
export default function Home() {
return (
<div>
<p>
Welcome to `fresh`. Try update this message in the ./pages/index.tsx
file, and refresh.
</p>
<Counter />
<p>{IS_BROWSER ? "Viewing browser render." : "Viewing JIT render."}</p>
</div>
);
}
function Counter() {
const [count, setCount] = useState(0);
return <div>
<p>{count}</p>
<button
onClick={() => setCount(count - 1)}
disabled={!IS_BROWSER}
>
-1
</button>
<button
onClick={() => setCount(count + 1)}
disabled={!IS_BROWSER}
>
+1
</button>
</div>;
}