22
packages/example/src/routes/__root.tsx
Normal file
22
packages/example/src/routes/__root.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Reffuse } from "@/reffuse"
|
||||
import { createRootRoute, Link, Outlet } from "@tanstack/react-router"
|
||||
import { TanStackRouterDevtools } from "@tanstack/router-devtools"
|
||||
|
||||
|
||||
export const Route = createRootRoute({
|
||||
component: Root
|
||||
})
|
||||
|
||||
function Root() {
|
||||
return (
|
||||
<Reffuse.Provider>
|
||||
<div className="container mx-auto flex-row justify-center items-center gap-2 mb-4">
|
||||
<Link to="/">Index</Link>
|
||||
<Link to="/count">Count</Link>
|
||||
</div>
|
||||
|
||||
<Outlet />
|
||||
<TanStackRouterDevtools />
|
||||
</Reffuse.Provider>
|
||||
)
|
||||
}
|
||||
27
packages/example/src/routes/count.tsx
Normal file
27
packages/example/src/routes/count.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Reffuse } from "@/reffuse"
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
import { Ref } from "effect"
|
||||
|
||||
|
||||
export const Route = createFileRoute("/count")({
|
||||
component: Count
|
||||
})
|
||||
|
||||
function Count() {
|
||||
|
||||
const runtime = Reffuse.useRuntime()
|
||||
|
||||
const countRef = Reffuse.useRef(0)
|
||||
const [count] = Reffuse.useRefState(countRef)
|
||||
|
||||
|
||||
return (
|
||||
<div className="container mx-auto">
|
||||
{/* <button onClick={() => setCount((count) => count + 1)}> */}
|
||||
<button onClick={() => Ref.update(countRef, count => count + 1).pipe(runtime.runSync)}>
|
||||
count is {count}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
10
packages/example/src/routes/index.tsx
Normal file
10
packages/example/src/routes/index.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: Index
|
||||
})
|
||||
|
||||
function Index() {
|
||||
return <></>
|
||||
}
|
||||
Reference in New Issue
Block a user