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

Better example code / tutorial? #45

Closed
ismailuddin opened this issue Sep 1, 2022 · 5 comments · Fixed by #48
Closed

Better example code / tutorial? #45

ismailuddin opened this issue Sep 1, 2022 · 5 comments · Fixed by #48

Comments

@ismailuddin
Copy link

I'm unable to get a simple example running with any of the example code on the website in a React Codesandbox. Is there any fully working example that can be provided?

import "./styles.css";
import React from "react";
import { Command } from "cmdk";

export default function App() {
  const loading = true;
  const setOpen = () => {};
  const open = true;

  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>

      <Command.Dialog open={open} onOpenChange={setOpen}>
        <Command.Input />

        <Command.List>
          {loading && <Command.Loading>Hang on…</Command.Loading>}

          <Command.Empty>No results found.</Command.Empty>

          <Command.Group heading="Fruits">
            <Command.Item>Apple</Command.Item>
            <Command.Item>Orange</Command.Item>
            <Command.Separator />
            <Command.Item>Pear</Command.Item>
            <Command.Item>Blueberry</Command.Item>
          </Command.Group>

          <Command.Item>Fish</Command.Item>
        </Command.List>
      </Command.Dialog>
    </div>
  );
}

https://codesandbox.io/s/wizardly-currying-x68myq

@tanmayairbase
Copy link

I faced the same, tried using previous versions and 0.1.16 works. Something got introduced in 0.1.17 it seems. You can do same till the error is fixed I guess

@pacocoursey
Copy link
Owner

That's weird, seems to be an issue with CRA specifically? Next.js works fine. Maybe something with esm/cjs.

@ismailuddin
Copy link
Author

In NextJS I have issues with conflicts with the minimum React version needed 18/17 between cmdk and radix UI, as well as hydration issues loading the page... 😕

@yusufbz
Copy link

yusufbz commented Sep 4, 2022

I'm facing the same issue now :/

@pomdtr
Copy link

pomdtr commented Sep 4, 2022

I fixed the issue by overriding one of the dependencies in the package.json:

  "overrides": {
    "@radix-ui/react-dialog": "1.0.0"
  }

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

Successfully merging a pull request may close this issue.

5 participants