You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/params.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -196,9 +196,9 @@ Avoid using `setParams` to update screen options such as `title` etc. If you nee
196
196
197
197
## Passing params to a previous screen
198
198
199
-
Params aren't only useful for passing some data to a new screen, but they can also be useful to pass data to a previous screen too. For example, let's say you have a screen with a create post button, and the create post button opens a new screen to create a post. After creating the post, you want to pass the data for the post back to previous screen.
199
+
Params aren't only useful for passing some data to a new screen, but they can also be useful to pass data to a previous screen as well. For example, let's say you have a screen with a "Create post" button, and the button opens a new screen to create a post. After creating the post, you want to pass the data for the post back to the previous screen.
200
200
201
-
To achieve this, you can use the `navigate` method, which acts like `goBack` if the screen already exists. You can pass the `params` with `navigate`to pass the data back:
201
+
To achieve this, you can use the `popTo` method to go back to the previous screen as well as pass paramsto it:
202
202
203
203
```js name="Passing params back" snack version=7
204
204
import*asReactfrom'react';
@@ -213,13 +213,16 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack';
213
213
functionHomeScreen({ route }) {
214
214
constnavigation=useNavigation();
215
215
216
+
// Use an effect to monitor the update to params
217
+
// highlight-start
216
218
React.useEffect(() => {
217
219
if (route.params?.post) {
218
220
// Post updated, do something with `route.params.post`
0 commit comments