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

catch all route not catch index route #402

Open
5 tasks done
JiangWeixian opened this issue Apr 17, 2023 · 1 comment
Open
5 tasks done

catch all route not catch index route #402

JiangWeixian opened this issue Apr 17, 2023 · 1 comment

Comments

@JiangWeixian
Copy link

JiangWeixian commented Apr 17, 2023

Describe the bug

Case 1

I have a project, pages dir looks like this:

./src/pages
├── [...all].tsx
└── blog
    └── [...all].tsx
    └── [id].tsx

When enter /blog/1 it display blog/[id].tsx, it's correct. But, when I enter /blog, it looks not fallback to catch all route(blog/[...all].tsx). Currently, it display nothing.

Case 2

./src/pages
├── [...all].tsx
└── blog
    └── [id].tsx

When I enter /blog, it looks not fallback to catch all route([...all].tsx). Currently, it display nothing.

Maybe it's related to resolved routes data, when routes data looks like this will meet above issue.

{
   path: 'blog'
   children: [
       {
            path: '*'
       }
   ]
}

The solution flat children routes(if parent route not found)

// if `blog.tsx` not exist
{
   path: 'blog/*',
   element: blog/[...all].tsx
}

// if `blog.tsx` exist
{
   path: 'blog',
   element: blog.tsx
   children: [
       {
            path: '*',
            element: [...all].tsx
       },
       {
            index: true,
            path: '',
            element: index.tsx
       }
   ]
}

Reproduction

https://github.com/JiangWeixian/vite-plugin-pages-minirepo

System Info

System:
    OS: macOS 12.5.1
    CPU: (10) x64 Apple M1 Max
    Memory: 164.31 MB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.20.1 - ~/.nvm/versions/node/v14.20.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v14.20.1/bin/yarn
    npm: 6.14.17 - ~/.nvm/versions/node/v14.20.1/bin/npm
  Browsers:
    Chrome: 112.0.5615.49
    Firefox: 111.0.1
    Safari: 15.6.1

Used Package Manager

pnpm

Validations

  • Follow the Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A please open a GitHub Discussion.
  • The provided reproduction is a minimal reproducible example of the bug.
@JiangWeixian
Copy link
Author

JiangWeixian commented Apr 17, 2023

Closed, I think it related to react-router.

remix-run/react-router#10357

@JiangWeixian JiangWeixian changed the title catch all route not display correct catch all route not display correct on nested routes Apr 17, 2023
@JiangWeixian JiangWeixian changed the title catch all route not display correct on nested routes catch all route not catch index route Apr 23, 2023
@JiangWeixian JiangWeixian reopened this Apr 23, 2023
@JiangWeixian JiangWeixian mentioned this issue Apr 23, 2023
7 tasks
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

1 participant