new example
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import { h, PageProps, useState } from "../deps.ts";
|
||||
import { h } from "../deps.ts";
|
||||
|
||||
export default function Home(props: PageProps) {
|
||||
const [counter, setCounter] = useState(0);
|
||||
|
||||
return (
|
||||
<div>
|
||||
Hello {props.params.name}! {counter}{" "}
|
||||
<button onClick={() => setCounter(counter + 1)}>+1</button>
|
||||
</div>
|
||||
);
|
||||
interface Props {
|
||||
params: {
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function Greet(props: Props) {
|
||||
return <div>Hello {props.params.name}</div>;
|
||||
}
|
||||
|
||||
+20
-3
@@ -1,5 +1,22 @@
|
||||
import { h } from "../deps.ts";
|
||||
import { h, useState } from "../deps.ts";
|
||||
|
||||
export default function Home(props: {}) {
|
||||
return <div>Hello World!</div>;
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<p>
|
||||
Welcome to `fresh`. Try update this message in the ./pages/index.tsx
|
||||
file, and refresh.
|
||||
</p>
|
||||
<Counter />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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>
|
||||
</div>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user