fix(core): fix cmdk not show current page (#6031)

This commit is contained in:
EYHN
2024-03-06 06:31:37 +00:00
parent 5d63ca0bab
commit 633a5bab53
2 changed files with 22 additions and 15 deletions

View File

@@ -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
);
}