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

This commit is contained in:
EYHN committed 2024-03-06 06:31:38 +00:00
1 parent 5d63ca0bab
commit 633a5bab53
2 files changed
+22 -15

No files matched your search

+10 -2
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
);
}