function Counter({start}) {
const [count, setCount] = useState(start ?? 0);
useEffect(() => {
console.log(`Count is now ${count}`)
}, [count]);
return (
<button onClick={() => setCount((c) => c + 1)}>
{count}
</button>
)
}
app.get("/counter", async (c) => [
const counterState = await db.getCounterState()
// Does not update properly, just stays at 0 forever.
return c.html(<Counter start={counterState} />);
})
function Counter({start}) {
const [count, setCount] = useState(start ?? 0);
useEffect(() => {
console.log(`Count is now ${count}`)
}, [count]);
return (
<button onClick={() => setCount((c) => c + 1)}>
{count}
</button>
)
}
app.get("/counter", async (c) => [
const counterState = await db.getCounterState()
// Does not update properly, just stays at 0 forever.
return c.html(<Counter start={counterState} />);
})