Skip to content

Commit

Permalink
fix: useSyncExternalStore backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
MateoKruk committed Aug 5, 2024
1 parent 92344c5 commit 2366822
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"dependencies": {
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-id": "^1.0.1",
"@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"
Expand Down
3 changes: 2 additions & 1 deletion cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof Primitive.div>
Expand Down Expand Up @@ -1013,7 +1014,7 @@ function mergeRefs<T = any>(refs: Array<React.MutableRefObject<T> | React.Legacy
function useCmdk<T = any>(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(
Expand Down
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2366822

Please sign in to comment.