Replies: 3 comments
-
|
Not sure I understood correctly. Does this clarify?
The exact approach depends on your use case. If these are the only 2 screens you want to pass params back to, then I'd just pass the screen name as param when pushing, then have 2 navigation calls conditionally: if (route.params.fromScreen === 'ScreenA') {
navigation.popTo(..) // go to ScreenA and pass params
} else {
navigation.popTo(..) // go to ScreenB and pass params
}On another note, |
Beta Was this translation helpful? Give feedback.
-
|
Hey @astrahov , the maintainer's reply actually gives you the answer. Here's the summary: 1. 2. For the "which screen called me?" problem, pass the caller's name as a param when pushing: // SomeScreen.tsx
navigation.push('ModalScreen', { fromScreen: 'SomeScreen' })
// OtherScreen.tsx
navigation.push('ModalScreen', { fromScreen: 'OtherScreen' })Then in if (route.params.fromScreen === 'SomeScreen') {
navigation.popTo('SomeStack', { screen: 'SomeScreen', params: { selectedValue } })
} else {
navigation.popTo('OtherStack', { screen: 'OtherScreen', params: { selectedValue } })
}3. Bonus tip from the maintainer , having Hope that clears it up! |
Beta Was this translation helpful? Give feedback.
-
|
For a picker/selection modal I would avoid making the modal know the whole nested route tree. Treat it as "return a result to whoever opened me": // caller
navigation.navigate('ModalScreen', {
requestId,
})
// modal
selectionStore.resolve(requestId, selectedValue)
navigation.goBack()Then the caller reads the result from a small store/context/query cache when it regains focus. This keeps Your |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've tried everything, but I can't solve the problem.
I have a modal screen where data is selected. Once selected, the data is sent to the screen that calls the selection screen.
This is possible, but how correct is it?
Beta Was this translation helpful? Give feedback.
All reactions