export { Page }
import React, { useState, Suspense } from 'react'
import { useAsync } from '../src/server/hooks'
function Page() {
return (
<>
Welcome
This page is:
-
Loading...}>
- Rendered to HTML.
-
Interactive.
-
loading on server}>
>
)
}
function Counter() {
const [count, setCount] = useState(0)
return (
)
}
function LazyComponent() {
const val = useAsync(
'hello-component-key',
() =>
new Promise((resolve) => {
setTimeout(() => resolve('Hello, I was lazy.'), 100)
}),
)
return {val}
}
function ErrorOnServer() {
// https://github.com/brillout/react-streaming#error-handling
if (typeof window === 'undefined') {
throw Error('Only renders on client')
}
return This text is only rendered on the client.
}