Skip to content

Commit

Permalink
refactor store creation for suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Sep 21, 2023
1 parent c13bd37 commit 68b6372
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/rx-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ export const useRxSuspense = <E, A>(
() => (options?.suspendOnWaiting ? suspenseRxWaiting(rx) : suspenseRx(rx)),
[options?.suspendOnWaiting, rx]
)
const result = useRxValue(resultRx)
const store = makeStore(registry, resultRx)
const result = React.useSyncExternalStore(store.subscribe, store.snapshot)
if (result._tag === "Suspended") {
if (!suspenseCache.has(resultRx)) {
const unmount = registry.mount(resultRx)
Expand Down

0 comments on commit 68b6372

Please sign in to comment.