Skip to content

Commit e0a377c

Browse files
committed
Add getServerSnapshot, fix loop on SSR Subscribe
1 parent 963ff94 commit e0a377c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/core/src/Subscribe.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export const Subscribe: React.FC<{
125125

126126
return fallback === undefined ? (
127127
actualChildren
128+
) : subscribedSource === null ? (
129+
fallback
128130
) : (
129131
<Suspense fallback={fallback}>{actualChildren}</Suspense>
130132
)

packages/core/src/useStateObservable.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ type VoidCb = () => void
1414

1515
interface Ref<T> {
1616
source$: StateObservable<T>
17-
args: [(cb: VoidCb) => VoidCb, () => Exclude<T, SUSPENSE>]
17+
args: [
18+
(cb: VoidCb) => VoidCb,
19+
() => Exclude<T, typeof SUSPENSE>,
20+
() => Exclude<T, typeof SUSPENSE>,
21+
]
1822
}
1923

2024
export const useStateObservable = <O>(
@@ -46,7 +50,7 @@ export const useStateObservable = <O>(
4650

4751
callbackRef.current = {
4852
source$: null as any,
49-
args: [, gv] as any,
53+
args: [, gv, gv] as any,
5054
}
5155
}
5256

0 commit comments

Comments
 (0)