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

Router wont navigate back to parent path when nesting stack with dynamic params #744

Open
oliviercperrier opened this issue Jul 7, 2023 · 6 comments

Comments

@oliviercperrier
Copy link

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

npm

Summary

When nesting multiple Stack with dynamic params, i cant navigate back to the top parent.

For example with this router setup:

(home) -> /orders (Slot) -> /[id] (Stack) -> /products (Stack) -> /[productId] -> /details (Stack)

from /orders/1/products/1/details, using a Link or calling router.push('/orders/1') wont do anything.

Minimal reproducible example

https://github.com/oliviercperrier/expo-router-mre

@oliviercperrier oliviercperrier changed the title Router wont navigate back to parent path when nesting stack Router wont navigate back to parent path when nesting stack with dynamic params Jul 7, 2023
@EvanBacon
Copy link
Contributor

EvanBacon commented Jul 8, 2023

unclear how to repro with the provided repo. Additionally, nesting stacks inside of other stacks will often not work.

Simulator Screenshot - iPhone 14 Pro - 2023-07-07 at 18 47 44

@oliviercperrier
Copy link
Author

unclear how to repro with the provided repo. Additionally, nesting stacks inside of other stacks will often not work.

Simulator Screenshot - iPhone 14 Pro - 2023-07-07 at 18 47 44

@EvanBacon You need to follow these steps:

  • Go to /orders/1/products/1/- details
  • Click on the button "Go back to order" (it wont navigate back)

@oliviercperrier
Copy link
Author

@EvanBacon

so ive found why it wasnt working.

This file structure doesn't work.

It wont navigate from /accounts/[slug]/action/[programId] to /accounts/[slug] using router.push

Screenshot 2023-07-11 at 7 23 13 AM

But with this file structure, it does work. (See that removing index and giving it a name changed everything)

Now i can navigate from /accounts/[slug]/action/[programId]/allocate to /accounts/[slug] using router.push

Screenshot 2023-07-11 at 7 23 49 AM

@lsps9150414
Copy link

lsps9150414 commented Sep 11, 2023

@oliviercperrier Facing a similar issue and I think your fix works out of luck. In your fix the /accounts/[slug] route matches the allocate.tsx file only because it is alphabetically the first match in the folder.

What if you move the index file to /accounts/[slug]/?

@oliviercperrier
Copy link
Author

oliviercperrier commented Sep 11, 2023

@lsps9150414

@oliviercperrier Facing a similar issue and I think your fix works out of luck. In your fix the /accounts/[slug] route matches the allocate.tsx file only because it is alphabetically the first match in the folder.

What if you move the index file to /accounts/[slug]/?

allocate.tsx is not under /accounts/[slug]/ its under /accounts/[slug]/action/[programId] so not sure how it would match /accounts/[slug]/

@lsps9150414
Copy link

@oliviercperrier oh, that's true my bad reading 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

3 participants