react-navigaton pop to screen in another stack

时间:2018-06-18 11:37:06

标签: react-native react-navigation

I have the following navigation scheme in my app. Using React-Navigation v2.

Main (Tab)
- Profile Stack (Stack)
  - Profile (Screen) - init
  - Settings (Screen)
  - ... (additional screens)
- Scan QR Code Stack (Stack)
  - Scan QR Code (Screen)
  - Filter Data based on qr code (Screen)
  - Filter Data of another type based on qr code (Screen)

so the scenario I am trying to accomplish is when the user scans the qr code i pick the correct Filter Data screen based on the qr code contents and show it to the user. Now when the user is on the Filter Data screen clicking back should not point him back to scan qr code but pick the Profile screen from another Stack. I tried so far the following

let reset = StackActions.reset({
      index: 1,
      actions: [
        NavigationActions.navigate({
          routeName: "Profile"
        }),
        NavigationActions.navigate({ routeName: "FilterDataScreen" })
      ]
    });

    this.props.navigation.dispatch(reset, {
      filter: parsedJwt.payloadObj.verified
    });

but with no luck. I end up with error that is saying that There is no route defined for key Profile, must be one of Scan QR Code, Filter Data, .. and only screen from the Scan QR Code Stack. Is this even possible?

0 个答案:

没有答案