mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
fix(core): fix cmdk not show current page (#6031)
This commit is contained in:
@@ -7,10 +7,14 @@ function noopSubscribe() {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
function noopGetSnapshot() {
|
||||
function nullGetSnapshot() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function undefinedGetSnapshot() {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* subscribe LiveData and return the value.
|
||||
*/
|
||||
@@ -25,7 +29,11 @@ export function useLiveData<Input extends LiveData<any> | null | undefined>(
|
||||
: never {
|
||||
return useSyncExternalStore(
|
||||
liveData ? liveData.reactSubscribe : noopSubscribe,
|
||||
liveData ? liveData.reactGetSnapshot : noopGetSnapshot
|
||||
liveData
|
||||
? liveData.reactGetSnapshot
|
||||
: liveData === undefined
|
||||
? undefinedGetSnapshot
|
||||
: nullGetSnapshot
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user