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
+2-3
Original file line number
Diff line number
Diff line change
@@ -398,7 +398,6 @@ However, this is an anti-pattern. There are many reasons why this is a bad idea:
398
398
- The same data is duplicated in multiple places. This can lead to bugs such as the profile screen showing outdated data even if the user object has changed after navigation.
399
399
- Each screen that navigates to the `Profile` screen now needs to know how to fetch the user object - which increases the complexity of the code.
400
400
- URLs to the screen (browser URL on the web, or deep links on native) will contain the user object. This is problematic:
401
-
402
401
1. Since the user object is in the URL, it's possible to pass a random user object representing a user that doesn't exist or has incorrect data in the profile.
403
402
2. If the user object isn't passed or improperly formatted, this could result in crashes as the screen won't know how to handle it.
404
403
3. The URL can become very long and unreadable.
@@ -409,11 +408,11 @@ A better way is to pass only the ID of the user in params:
Now, you can use the passed `userId` to grab the user from your global store. This eliminates a host of issues such as outdated data, or problematic URLs.
411
+
Now, you can use the passed `userId` to grab the user from your global cache or fetch it from the API. Using a library such as [React Query](https://tanstack.com/query/) can simplify this process since it makes it easy to fetch and cache your data. This approach helps to avoid the problems mentioned above.
413
412
414
413
Some examples of what should be in params are:
415
414
416
-
1. IDs like user id, item id etc., e.g. `navigation.navigate('Profile', { userId:'Jane' })`
415
+
1. IDs such as user id, item id etc., e.g. `navigation.navigate('Profile', { userId:'Jane' })`
417
416
2. Params for sorting, filtering data etc. when you have a list of items, e.g. `navigation.navigate('Feeds', { sortBy:'latest' })`
418
417
3. Timestamps, page numbers or cursors for pagination, e.g. `navigation.navigate('Chat', { beforeTime:1603897152675 })`
419
418
4. Data to fill inputs on a screen to compose something, e.g. `navigation.navigate('ComposeTweet', { title:'Hello world!' })`
Copy file name to clipboardExpand all lines: versioned_docs/version-7.x/testing.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -758,6 +758,6 @@ In the above test, we:
758
758
759
759
:::note
760
760
761
-
In a production app, we recommend using a library like [React Query](https://react-query.tanstack.com/) to handle data fetching and caching. The above example is for demonstration purposes only.
761
+
In a production app, we recommend using a library like [React Query](https://tanstack.com/query/) to handle data fetching and caching. The above example is for demonstration purposes only.
0 commit comments