Files
reffuse/packages/example/src/routes/count.tsx
Julien Valverdé 5430d8daa4
Some checks failed
Publish / publish (push) Failing after 13s
Lint / lint (push) Successful in 11s
0.1.0 (#1)
Co-authored-by: Julien Valverdé <julien.valverde@mailo.com>
Reviewed-on: https://gitea:3000/Thilawyn/reffuse/pulls/1
2025-01-18 00:54:42 +01:00

28 lines
631 B
TypeScript

import { R } from "@/reffuse"
import { createFileRoute } from "@tanstack/react-router"
import { Ref } from "effect"
export const Route = createFileRoute("/count")({
component: Count
})
function Count() {
const runSync = R.useRunSync()
const countRef = R.useRef(0)
const [count] = R.useRefState(countRef)
return (
<div className="container mx-auto">
{/* <button onClick={() => setCount((count) => count + 1)}> */}
<button onClick={() => Ref.update(countRef, count => count + 1).pipe(runSync)}>
count is {count}
</button>
</div>
)
}