Let myObservable: Observable<() => string> = of(() => "hello"). If you try to consume this observable from React using useObservableEagerState, you would expect to get a value of type () => string, but sometimes you actually get a string. Here's a full example:
const myObservable = of(() => "hello")
const MyComponent: FC = () => {
const value = useObservableEagerState(myObservable)
useEffect(() => console.log(`value is ${value}`), [value])
return null
}
Expected result: When MyComponent is mounted, value is function value() is logged to the console.
Actual result:value is hello is sometimes logged to the console.
I suspect this is due to useState accepting a function, which it will call to determine its initial value.
Let
myObservable: Observable<() => string> = of(() => "hello")
. If you try to consume this observable from React usinguseObservableEagerState
, you would expect to get a value of type() => string
, but sometimes you actually get astring
. Here's a full example:Expected result: When MyComponent is mounted,
value is function value()
is logged to the console. Actual result:value is hello
is sometimes logged to the console.I suspect this is due to
useState
accepting a function, which it will call to determine its initial value.