Skip to content

Commit

Permalink
use store.snapshot for getServerSnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Dec 19, 2023
1 parent 6fbff2c commit f005658
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-seals-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-rx/rx-react": patch
---

use store.snapshot for getServerSnapshot
6 changes: 1 addition & 5 deletions packages/rx-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const RegistryContext = React.createContext<Registry.Registry>(Registry.m
interface RxStore<A> {
readonly subscribe: (f: () => void) => () => void
readonly snapshot: () => A
readonly serverSnapshot: () => A
}

const storeRegistry = globalValue(
Expand All @@ -60,9 +59,6 @@ function makeStore<A>(registry: Registry.Registry, rx: Rx.Rx<A>): RxStore<A> {
},
snapshot() {
return registry.get(rx)
},
serverSnapshot() {
return undefined as any
}
}
stores.set(rx, newStore)
Expand All @@ -71,7 +67,7 @@ function makeStore<A>(registry: Registry.Registry, rx: Rx.Rx<A>): RxStore<A> {

function useStore<A>(registry: Registry.Registry, rx: Rx.Rx<A>): A {
const store = makeStore(registry, rx)
return React.useSyncExternalStore(store.subscribe, store.snapshot, store.serverSnapshot)
return React.useSyncExternalStore(store.subscribe, store.snapshot, store.snapshot)
}

/**
Expand Down

0 comments on commit f005658

Please sign in to comment.