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

Unexpected behaviour of dynamic routes with rest syntax #544

Open
riebel opened this issue May 5, 2023 · 1 comment
Open

Unexpected behaviour of dynamic routes with rest syntax #544

riebel opened this issue May 5, 2023 · 1 comment

Comments

@riebel
Copy link

riebel commented May 5, 2023

Which package manager are you using? (Yarn is recommended)

yarn

Summary

I have a basic layout.

  • App Index screen app/index.tsx
  • Two screens with dynamic routes:
    • app/view/[...pathVariable].tsx
    • app/[...pathVariable]/index.tsx.

2023-05-05 10_25_08-expo-router rest parameter - CodeSandbox

The first dynamic route works fine (app/view/[...pathVariable].tsx).

If I push from / to /view/foo/bar everything works as expected and the URL looks like /view/foo/bar and has no GET parameters appended (which is what I expect).

On the second dynamic route, if I push from / to /foo/bar, I land on app/[...pathVariable]/index.tsx which is correct, but now GET parameters are being appended and the URL looks like /foo/bar?pathVariable=foo&pathVariable=bar

If I navigate from / to /foo/bar and then try / again, it does not navigate to app/index.tsx screen but removes the GET parameters. (And the URL is then still: /foo/bar)

Another oddity: If I go from / to /foo/bar then to /view/foo/bar and then back to /foo/bar the screen gets rerendered and usePathname var changes from /foo/bar to /foo/bar/ (console logs twice, extra slash at end) on this screen.

Are routes like app/[...pathVariable]/index.tsx supported?

Minimal reproducible example

Here is a working codesandbox showcasing this behaviour:

https://codesandbox.io/p/sandbox/vigilant-mclaren-zrq1kc

@riebel
Copy link
Author

riebel commented May 23, 2023

Would somebody be so nice and provide me some feedback?
Is this actually a bug, a missing feature or is it working as intended and I am just using it wrong?

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