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

It's a route param - not query string. If the parameter doesn't exist it means the route is different. #33

Open
luke-hanwook opened this issue Nov 10, 2023 · 1 comment

Comments

@luke-hanwook
Copy link
Owner

          It's a route param - not query string. If the parameter doesn't exist it means the route is different.

Let's say you have this configuration: /group/:groupId/post/:postId
If groupId is undefined the route will be /group/post/<postId> and if postId is undefined the route will be /group/<groupId>/post
These two examples should match different routes than /group/:groupId/post/:postId

A common convention is that path/route params are manditory while query params are optional.

Originally posted by @tzachov in remix-run/react-router#8498 (comment)

@yeliex
Copy link

yeliex commented Dec 20, 2023

the component should decide it can receive optionally params actually

eg:

const Page = () => {
    const params = useParams<{ id1: string; id2?: string }>;
}

const route = [
  {
      path: '/item/:id1/item2/:id2',
      Component: Page
  }, 
  {
    path: '/item/:id1',
    Component: Page
  }
];

the case should be defined in route manually and could be known by developer

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