Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js 14 App router layout.tsx: Fails to spawn the command palette #358

Open
Aymericr opened this issue May 1, 2024 · 2 comments
Open

Comments

@Aymericr
Copy link

Aymericr commented May 1, 2024

Fails to spawn the command palette.
I tried wrapping it into a 'use client' component but the issue keeps happening.

Dependencies:

  • Next.js 14.2.3
  • React 18
Error: Invariant failed: Input ref is undefined, make sure you attach `query.inputRefSetter` to your search input.

Call Stack
invariant
node_modules/tiny-invariant/dist/tiny-invariant.cjs.js (14:1)
Object.getInput
node_modules/kbar/lib/useStore.js (107:1)
handler
node_modules/kbar/lib/InternalEvents.js (277:1)

CleanShot 2024-05-01 at 11 53 48@2x

@0x33dm
Copy link

0x33dm commented Jul 22, 2024

did you manage to solve this?

@0x33dm
Copy link

0x33dm commented Jul 22, 2024

For me adding use client at the top of the provider ( which is them added to my root layout ) is yielding another error.

// KBarProvider.ts

'use client'

import {
  KBarAnimator,
  KBarPortal,
  KBarPositioner,
  KBarProvider as OriginalKBarProvider,
  KBarSearch
} from 'kbar'
import type { ReactNode } from 'react'

interface Props {
  children: ReactNode
}

const KBarProvider = ({ children }: Props) => {
  return (
    <OriginalKBarProvider>
      <KBarPortal>
        <KBarPositioner>
          <KBarAnimator>
            <KBarSearch />
            {/* <KBarResults /> */}
          </KBarAnimator>
        </KBarPositioner>
      </KBarPortal>
      {children}
    </OriginalKBarProvider>
  )
}

export default KBarProvider

The error i get is:

Caution

TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants