Closed npinney closed 1 year ago
We have a similar issue in that we're using navigationRef
to navigate within the app from outside of the NavigationContainer
(without the navigation prop) as described in here: https://reactnavigation.org/docs/navigating-without-navigation-prop. This is used for navigation for a press in a push notification. Recent Pendo SDK upgrade (in v. 2.21.1) and a change in implementation (using WithPendoReactNavigation(NavigationContainer
)) breaks using refs with NavigationContainer
. I tried forwarding refs to PendoNavigationContainer
, but it does not seem to register the ref or any navigation state changes.
My code with ref forwarding:
import { JSX, ReactNode, RefObject, forwardRef } from 'react'
import {
NavigationContainer,
NavigationContainerRef,
} from '@react-navigation/native'
import { AppThemeTypes } from 'react-native-paper'
import { WithPendoReactNavigation } from 'rn-pendo-sdk'
interface Props {
appTheme: AppThemeTypes
children: ReactNode
handleOnReady: () => void
handleOnStateChange: () => void
}
const PendoNavigationContainer = WithPendoReactNavigation(NavigationContainer)
function AppNavigationContainer(
{ appTheme, children, handleOnReady, handleOnStateChange }: Props,
inputRef: RefObject<NavigationContainerRef>
): JSX.Element {
return (
<PendoNavigationContainer
ref={inputRef}
theme={appTheme}
onReady={handleOnReady}
onStateChange={handleOnStateChange}
>
{children}
</PendoNavigationContainer>
)
}
export default forwardRef((props, ref) => {
return <AppNavigationContainer {...props} inputRef={ref} />
})
My handleOnReady
and handleOnStateChange
functions:
const handleOnReady = () => {
const currentRef = navigationRef.current
// currentRef is always null here
if (currentRef) {
const currentRoute = currentRef.getCurrentRoute()
if (currentRoute) {
routeNameRef.current = currentRoute.name
}
}
}
const handleOnStateChange = async () => {
const previousRouteName = routeNameRef.current
let currentRouteName
const currentRef = navigationRef.current
// currentRef is always null here
if (currentRef) {
const currentRoute = currentRef.getCurrentRoute()
if (currentRoute) {
currentRouteName = currentRoute.name
routeNameRef.current = currentRoute.name
}
}
if (previousRouteName !== currentRouteName) {
await analytics().logScreenView({
screen_name: currentRouteName,
screen_class: currentRouteName,
})
}
}
Please help solving this issue. This is delaying a release to production for us.
@vlad-ps @npinney We r looking into it
I see there is no issue with previous Pendo Integration, you still can use the old integration. (the underhood implementation of both integrations is equivalent). We need to see why we have that issue
@npinney ok I think I found the issue, we will update u as soon as we release
Issue was found and fixed. It will be available in our 2.21.2 release (should be next week)
@udilevin Thank you!
@udilevin @MikePendo Thanks!
rn-pendo-sdk 2.21.2 was released today. Please update your plugin.
@vlad-ps @npinney ☝️
@udilevin @MikePendo Thank you so much, I just updated rn-pendo-sdk
to the recent version 2.21.2
, and the ref started working on PendoNavigationContainer
right out of the box, without the need to use forwardRef
.
Version 2.21.2 completely fixes the issue I was having when using refs with the PendoNavigationContainer
.
Unfortunately I've been getting this error. I believe they are the same error they've just been showing differently on iOS and Android. I was getting this on my sentry branch so I tried on a clean branch without it which was working with 2.21.1, updated to 2.21.2 but still getting this same error.
I wasn't able to reproduce using your repo, i'll do some more testing in my project and let you know if I find anything.
I am also continuing to see errors after this update. Pendo is not recognizing any activity in the app with WithPendoReactNavigation
but it still does with withPendoRN
. Refs are not being recognized with the new wrapper.
also seeing:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `PNDContainer`.
in NavContainer (created by PNDContainer)
in PNDContainer
I've created a beta version for you @dgasch512 @npinney https://drive.google.com/file/d/1ZecX9EXJlN1iZ5LDDpaEmOeHAgtBQGWQ/view?usp=sharing Can you please download, verify and let me know. I will release once all issues are resolved.
@dgasch512 can you share the code using the Pendo Plugin? I would like to try and replicate on my end.
@udilevin @MikePendo After making the following change (with 2.21.2) everything works flawlessly. No warnings, no errors, and can confirm I am receiving the pendo (and sentry) events in the web console! Thanks for your help! 🙂
const PendoNavigationContainer = WithPendoReactNavigation(
NavigationContainer,
{ nativeIDs: ['pendo'] },
);
return (
<PendoNavigationContainer
linking={linking}
ref={navigation}
onReady={() => {
routingInstrumentation.registerNavigationContainer(navigation);
}}>
+ <RootNavigation />
- {RootNavigation()}
</PendoNavigationContainer>
);
@npinney So just to make sure u didn't use the google drive link? u used the released one 2.21.2 right? https://drive.google.com/file/d/1ZecX9EXJlN1iZ5LDDpaEmOeHAgtBQGWQ/view?usp=sharing
@MikePendo Yes correct
@dgasch512 Can u please see if u still have the issue?
@dgasch512 I am closing the issue please feel to write us if u still have it.
Hi Pendo devs!
I'm having compatibility difficulties between Pendo and Sentry in our React Native app and am wondering if you guys could help us out. Because both softwares require access to the
NavigationContainer
there is a bit of a conflict to get both third parties registered with the container.This is the basic Sentry configuration at the root navigation level (imports and exports omitted):
After following the Pendo docs our root navigation turned into:
Now with the Pendo wrapper, Sentry produces
WARN Sentry Logger [warn]: [ReactNavigationInstrumentation] Received invalid navigation container ref!
and no longer automatically registers navigation state changes.Does the Pendo wrapper modify the ref in any way not allowing this to work? Are there other ways we can setup the
WithPendoReactNavigation()
that might help us get both third parties working?Thank you for you time!
Relevant packages :