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

[Bug]: Error no route matches URL / v6.22.1 with Create react app #11311

Closed
AsuraKev opened this issue Feb 27, 2024 · 3 comments
Closed

[Bug]: Error no route matches URL / v6.22.1 with Create react app #11311

AsuraKev opened this issue Feb 27, 2024 · 3 comments
Labels

Comments

@AsuraKev
Copy link

What version of React Router are you using?

6.22.1

Steps to Reproduce

A route config that looks like
image

The default layout has no path as its a layout route. However this issue doesnt happen to my other project thats on Vite so I am wondering if React router v6.19 above doesnt work with Create react app?

image

thanks!

Expected Behavior

Based on the the screenshot, React router should find DefaultLayout and start rendering it

Actual Behavior

No path matched / because no path were specified

@AsuraKev AsuraKev added the bug label Feb 27, 2024
@AsuraKev
Copy link
Author

AsuraKev commented Feb 27, 2024

Issues are gone after specifying path. I thought path is optional?!

image

@brophdawg11
Copy link
Contributor

Pathless routes don't "match" as leaf routes. If you want to match / you need to provide an index route for the pathless layout route, or add path="/" as you discovered. Right now only the two path'd children would match - so /litmos-group-signup and /education-group-signup.

const routes = [
  {
    element: <Layout />,
    children: [
      {
        index: true, // match at the path "/"
        element: <h2>Index</h2>,
      },
      {
        path: "temp",
        element: <h2>Temp</h2>,
      },
    ],
  },
];

@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
@johnnyreilly
Copy link
Contributor

If you've landed on this page, it might be because you're being bitten by this issue: #11480

Putting a link here just to help connect folk

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

No branches or pull requests

3 participants