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
This package is designed to streamline your workflow by requiring minimal setup. To use this package, you only need to pass a reference and a optionally provider (the global one will be used by default)
22
+
This package is designed to streamline your workflow by requiring minimal setup. To use this package, you only need to pass a reference and a optionally provider (the global one will be used by default).
23
+
24
+
### Expo Router / React Native Navigation
23
25
24
26
If you are using `expo-router` or `react-native/navigation` you need to wrap your entire application with the `NavigationTracker` component.
25
27
@@ -30,7 +32,8 @@ import {NavigationTracker} from '@opentelemetry/instrumentation-react-native-nav
constnavigationRef=useNavigationContainerRef(); // if you do not use `expo-router` the same hook is also available in `@react-navigation/native` since `expo-router` is built on top of it. Just make sure this ref is passed also to the navigation container at the root of your app (if not, the ref would be empty and you will get a console.warn message instead).
35
+
// if you do not use `expo-router` the same hook is also available in `@react-navigation/native` since `expo-router` is built on top of it. Just make sure this ref is passed also to the navigation container at the root of your app (if not, the ref would be empty and you will get a console.warn message instead).
36
+
constnavigationRef=useNavigationContainerRef();
34
37
35
38
constprovider=useProvider(); // the provider is something you need to configure and pass down as prop into the `NavigationTracker` component (this hook is not part of the package, it is just used here as a reference)
36
39
// If your choice is not to pass any custom tracer provider, the <NavigationTracker /> component will use the global one.
@@ -61,6 +64,49 @@ const App: FC = () => {
61
64
exportdefaultApp;
62
65
```
63
66
67
+
If you are using the `useNavigationContainerRef()` from the `@react-navigation/native` package please make sure you wrap what it returns into the proper shape of a reference (i.e `{ current: { <useNavigationContainerRef value> } }`), otherwise it won't work as expected and you will see the mentioned console.warn message insted (in case `debug` mode is enabled).
// Trick: if you inspect the source code of `useNavigationContainerRef` from `@react-navigation/native` you will see that it returns `navigation.current` instead of the entire shape of a reference.
If you are using `wix/react-native-navigation` you are also able to track navigation changes by importing and implement the `NativeNavigationTracker` component. The purpose in here is to wrap the entire application with the exposed component.
0 commit comments