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
{{ message }}
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
docs: update screen tracking for React Navigation (segmentio#553)
Currently, the documentation for screen tracking in React Navigation requires manually implementing a utility to determine the focused screen and can also result in `Unknown` screen. This updates the documentation to follow the official React Navigation docs to use the built-in methods instead.
The example app also needs to be updated, but currently, I don't have time to do this.
Note: I didn't use `useNavigationRef` to stay compatible with React Navigation 5.
Docs: https://reactnavigation.org/docs/screen-tracking
Copy file name to clipboardExpand all lines: README.md
+14-28Lines changed: 14 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -372,42 +372,28 @@ Our [example app](./example) is set up with screen tracking using React Navigati
372
372
373
373
Essentially what we'll do is find the root level navigation container and call `screen()` whenever user has navigated to a new screen.
374
374
375
-
Find the file where you've used the `NavigationContainer` - the main top level container for React Navigation. In this component, create a new state variable to store the current route name:
375
+
Find the file where you've used the `NavigationContainer` - the main top level container for React Navigation. In this component, create 2 new refs to store the `navigation` object and the current route name:
Finally, pass a function in the `onStateChange` prop of your `NavigationContainer` that checks for the active route name and calls `client.screen()` if the route has changes. You can pass in any additional screen parameters as the second argument for screen call as needed.
382
+
Next, pass the ref to `NavigationContainer` and a function in the `onReady` prop to store the initial route name. Finally, pass a function in the `onStateChange` prop of your `NavigationContainer` that checks for the active route name and calls `client.screen()` if the route has changes. You can pass in any additional screen parameters as the second argument for screen call as needed.
0 commit comments