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

add easier system for popping multiple screens in a stack #479

Open
CodySwannGT opened this issue Apr 11, 2023 · 2 comments
Open

add easier system for popping multiple screens in a stack #479

CodySwannGT opened this issue Apr 11, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@CodySwannGT
Copy link

Summary

Given this navigation, I want the links to act like bottom tabs.

  1. If you are drilled down into "Buy" nav and click "Buy", the app replaces the nav stack with the '/buy' route which is the initial screen for that tab
  2. If you are drilled down into the "Sell" nav and click "Buy", the app jumpsTo the Buy tab. If you click back to "Sell" the app takes you to the last screen you were on

However, if I'm drilled down into "Buy" and click "Buy" (which calls replace('/buy'), nothing happens

Minimal reproducible example

  const segments = useSegments();
  const currentSegment = segments.slice(-1)[0];
  const isInPath = segments.includes(segment);
  const isCurrent = currentSegment === segment;
  const router = useRouter();

  const handlePress = useCallback(
    () =>
      isCurrent
        ? null
        : isInPath
        ? router.replace(`/${segment}`)
        : navigator.jumpTo(segment),
    [isCurrent, isInPath, router, segment, navigator]
  );
@WKampel
Copy link

WKampel commented Apr 24, 2023

Did you ever figure this out?

@CodySwannGT
Copy link
Author

@WKampel no. I don't think there's a way to make it work with router right now. As a workaround, I used navigation.popToTop()

@EvanBacon EvanBacon changed the title router.replace doesn't appear to be working add easier system for popping multiple screens in a stack Jul 17, 2023
@EvanBacon EvanBacon added the enhancement New feature or request label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants