update example
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
export * from "../runtime.ts";
|
||||
export * from "file:///mnt/starship/Projects/github.com/lucacasonato/fresh/runtime.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { h, useState } from "../deps.ts";
|
||||
import { h, IS_BROWSER, useState } from "../deps.ts";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
@@ -8,6 +8,7 @@ export default function Home() {
|
||||
file, and refresh.
|
||||
</p>
|
||||
<Counter />
|
||||
<p>{IS_BROWSER ? "Viewing JIT render." : "Viewing browser render."}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -16,7 +17,11 @@ function Counter() {
|
||||
const [count, setCount] = useState(0);
|
||||
return <div>
|
||||
<p>{count}</p>
|
||||
<button onClick={() => setCount(count - 1)}>-1</button>
|
||||
<button onClick={() => setCount(count + 1)}>+1</button>
|
||||
<button onClick={() => setCount(count - 1)} disabled={!IS_BROWSER}>
|
||||
-1
|
||||
</button>
|
||||
<button onClick={() => setCount(count + 1)} disabled={!IS_BROWSER}>
|
||||
+1
|
||||
</button>
|
||||
</div>;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// This file SHOULD be checked into source version control.
|
||||
// To update this file, run `fresh routes`.
|
||||
|
||||
import { setup } from "../server.ts";
|
||||
import { setup } from "file:///mnt/starship/Projects/github.com/lucacasonato/fresh/server.ts";
|
||||
|
||||
import * as $0 from "./pages/[name].tsx";
|
||||
import * as $1 from "./pages/index.tsx";
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./src/runtime/deps.ts";
|
||||
export * from "./src/runtime/types.ts";
|
||||
export * from "./src/runtime/utils.ts";
|
||||
|
||||
+8
-3
@@ -60,7 +60,7 @@ async function init(directory: string) {
|
||||
import.meta.url,
|
||||
)}";\n`;
|
||||
await Deno.writeTextFile(join(directory, "deps.ts"), DEPS_TS);
|
||||
const PAGES_INDEX_TSX = `import { h, useState } from "../deps.ts";
|
||||
const PAGES_INDEX_TSX = `import { h, IS_BROWSER, useState } from "../deps.ts";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
@@ -70,6 +70,7 @@ export default function Home() {
|
||||
file, and refresh.
|
||||
</p>
|
||||
<Counter />
|
||||
<p>{IS_BROWSER ? "Viewing JIT render." : "Viewing browser render."}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -78,8 +79,12 @@ function Counter() {
|
||||
const [count, setCount] = useState(0);
|
||||
return <div>
|
||||
<p>{count}</p>
|
||||
<button onClick={() => setCount(count - 1)}>-1</button>
|
||||
<button onClick={() => setCount(count + 1)}>+1</button>
|
||||
<button onClick={() => setCount(count - 1)} disabled={!IS_BROWSER}>
|
||||
-1
|
||||
</button>
|
||||
<button onClick={() => setCount(count + 1)} disabled={!IS_BROWSER}>
|
||||
+1
|
||||
</button>
|
||||
</div>;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const IS_BROWSER = typeof document !== "undefined";
|
||||
Reference in New Issue
Block a user