2

Per the RN documentation, the proper way to use merge is as follows:

navigation.navigate({
  name: 'Post',
  params: { postTitle: 'An okay post' },
  merge: true,
});

I'd like to use merge in my app, however my navigate function looks a bit different:

navigation.navigate("mainScreen", { screen: "secondaryScreen" })

I want the route params that were initially passed to mainScreen to persist. I know that I can use merge: true like in the documentation. However my navigate function is a bit different, and I'm not sure where to put merge:true. Is there a proper place for this, or is there a way that I can translate my navigate function to look like the one in the documentation?

Francesco - FL
  • 603
  • 1
  • 4
  • 25

1 Answers1

1
navigation.navigate({
   name: 'mainScreen',
   params: { screen: secondaryScreen },
   merge: true,
});

But if you're coding in Typescript, you will get a compilation error. I have the same problem. I end up adding @ts-ignore to ignore the type checking.

Jing
  • 21
  • 1