pacocoursey / cmdk

Fast, unstyled command menu React component.
https://cmdk.paco.me
MIT License
9.42k stars 265 forks source link

Error when using useCommandState #54

Closed mrmartineau closed 1 year ago

mrmartineau commented 1 year ago

I have just added useCommandState to my cmdk component and before anything is even typed this error is shown. I am using the latest version of next.js (v12.3.1), React (v18.2.0) and cmdk (v0.1.20). Do you have any idea why this might be occurring? Is there anything else that I need to add in order for this to work?

Usage

const search = useCommandState((state) => state.search)

Error

TypeError: Cannot read properties of undefined (reading 'subscribe')
joaom00 commented 1 year ago

The useCommandState hook must be used below the Command component

mrmartineau commented 1 year ago

Thanks @joaom00, the docs do not state that this hook relates to React context.