diff --git a/cmdk/package.json b/cmdk/package.json index 3a09642..8c4ae99 100644 --- a/cmdk/package.json +++ b/cmdk/package.json @@ -28,7 +28,8 @@ "dependencies": { "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-id": "^1.1.0", - "@radix-ui/react-primitive": "^2.0.0" + "@radix-ui/react-primitive": "^2.0.0", + "use-sync-external-store": "^1.2.2" }, "devDependencies": { "@types/react": "18.0.15" diff --git a/cmdk/src/index.tsx b/cmdk/src/index.tsx index 1547b27..6f4c9e0 100644 --- a/cmdk/src/index.tsx +++ b/cmdk/src/index.tsx @@ -3,6 +3,7 @@ import * as React from 'react' import { commandScore } from './command-score' import { Primitive } from '@radix-ui/react-primitive' import { useId } from '@radix-ui/react-id' +import { useSyncExternalStore } from 'use-sync-external-store' type Children = { children?: React.ReactNode } type DivProps = React.ComponentPropsWithoutRef @@ -1013,7 +1014,7 @@ function mergeRefs(refs: Array | React.Legacy function useCmdk(selector: (state: State) => T) { const store = useStore() const cb = () => selector(store.snapshot()) - return React.useSyncExternalStore(store.subscribe, cb, cb) + return useSyncExternalStore(store.subscribe, cb, cb) } function useValue( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e992dd2..3ee54c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: react-dom: specifier: ^18 || ^19 || ^19.0.0-rc version: 18.2.0(react@18.2.0) + use-sync-external-store: + specifier: ^1.2.2 + version: 1.2.2(react@18.2.0) devDependencies: '@types/react': specifier: 18.0.15 @@ -4336,6 +4339,14 @@ packages: tslib: 2.6.2 dev: false + /use-sync-external-store@1.2.2(react@18.2.0): + resolution: {integrity: sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.2.0 + dev: false + /v8-compile-cache@2.3.0: resolution: {integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==} dev: true