Skip to content

Commit

Permalink
Update hook name in README (#41)
Browse files Browse the repository at this point in the history
The hook name in readme is apparently wrong.
  • Loading branch information
caumeira authored Aug 21, 2022
1 parent 8477246 commit 3760c39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ const [loading, setLoading] = React.useState(false)
return <Command.List>{loading && <Command.Loading>Hang on…</Command.Loading>}</Command.List>
```

### `useCmdk(state => state.selectedField)`
### `useCommandState(state => state.selectedField)`

Hook that composes [`useSyncExternalStore`](https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore). Pass a function that returns a slice of the command menu state to re-render when that slice changes. This hook is provided for advanced use cases and should not be commonly used.

A good use case would be to render a more detailed empty state, like so:

```tsx
const search = useCmdk((state) => state.search)
const search = useCommandState((state) => state.search)
return <Command.Empty>No results found for "{search}".</Command.Empty>
```

Expand Down Expand Up @@ -292,7 +292,7 @@ If your items have nested sub-items that you only want to reveal when searching,

```tsx
const SubItem = (props) => {
const search = useCmdk((state) => state.search)
const search = useCommandState((state) => state.search)
if (!search) return null
return <Command.Item {...props} />
}
Expand Down

1 comment on commit 3760c39

@vercel
Copy link

@vercel vercel bot commented on 3760c39 Aug 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cmdk-website – ./

cmdk.vercel.app
cmdk-website-git-main-paco.vercel.app
cmdk.paco.me
cmdk-website-paco.vercel.app

Please sign in to comment.