Add debugging

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Ayase Minori 2023-09-11 04:30:34 +00:00 committed by GitHub
parent 78a43c846e
commit 062a03c708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -5,7 +5,7 @@ import axios from "axios-web";
interface SharedProps {
hasClicked: Signal<boolean>;
globalCount: string;
globalCount: Signal<number>;
}
export default function Counter(props: SharedProps) {
@ -72,7 +72,7 @@ export default function Counter(props: SharedProps) {
</div>
<div class="px-6 pt-4 pb-2">
<p>
Everyone has clicked the button {parseInt(props.globalCount)} times!
Everyone has clicked the button {props.globalCount} times!
</p>
</div>
</div>

View file

@ -42,13 +42,14 @@ export const handler: Handlers = {
// broadcast new value to everyone
const bc = new BroadcastChannel("global-count");
bc.postMessage(getGlobalStatistics().toString());
return Response.json({ success: true })
}
}
export default function Home(data: string) {
export default function Home() {
const hasClicked = useSignal(false);
const globalCount = useSignal(0);
return (
<div class="px-4 py-8 mx-auto bg-[#9d88d3]">
<div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
@ -58,7 +59,7 @@ export default function Home(data: string) {
<code class="mx-2">./routes/index.tsx</code> file, and refresh.
</p>
<Counter
globalCount={data}
globalCount={globalCount}
hasClicked={hasClicked}/>
</div>
</div>