Skip to content

Commit 6bf1f31

Browse files
authored
prevent suspend when initialValue is null (#177)
1 parent 49437e1 commit 6bf1f31

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

reactfire/useObservable/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ export function useObservable(
3737

3838
const request = requestCache.getRequest(observable$, observableId);
3939

40-
const initialValue =
41-
request.value ||
42-
startWithValue ||
43-
suspendUntilFirst(observable$, observableId);
40+
let initialValue;
41+
42+
if (request.value !== undefined) {
43+
initialValue = request.value;
44+
} else if (startWithValue !== undefined) {
45+
initialValue = startWithValue;
46+
} else {
47+
initialValue = suspendUntilFirst(observable$, observableId);
48+
}
4449

4550
const [latestValue, setValue] = React.useState(initialValue);
4651

0 commit comments

Comments
 (0)