Closed nvacheishvili closed 6 months ago
@nvacheishvili
Can you try to move const PendoNavigationContainer = WithPendoReactNavigation(NavigationContainer);
out of NavigationSetup
(in general its a best practice)
Hi @MikePendo for sure, should it be an exportable constant do you think in the NavigationService file or do you imagine it to be inside App.js file?
just inside the App.js I mean lets first see and try if that resolve the issue.
I did both approaches and none of them helped
const PendoNavigationContainer =
WithPendoReactNavigation(NavigationContainer);
const routeNameRef = React.useRef();
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<SplitContext.Provider value={splitValue}>
<NetworkProvider />
<NativeBaseProvider theme={nativeBaseThemeSetup}>
<React.Fragment>
<PendoNavigationContainer
ref={navigationRef}
onReady={() => {
routeNameRef.current =
navigationRef.current.getCurrentRoute().name;
}}
onStateChange={async () => {
const previousRouteName = routeNameRef.current;
const currentRouteName =
navigationRef.current.getCurrentRoute().name;
if (previousRouteName !== currentRouteName) {
await analytics().logScreenView({
screen_name: currentRouteName,
screen_class: currentRouteName,
});
}
routeNameRef.current = currentRouteName;
}}>
<RootNavigation />
</PendoNavigationContainer>
</React.Fragment>
</NativeBaseProvider>
</SplitContext.Provider>
</PersistGate>
</Provider>
);
import * as React from 'react';
import RootNavigation from './RootNavigation';
import analytics from '@react-native-firebase/analytics';
import {navigationRef, PendoNavigationContainer} from './NavigationService'; // import {WithPendoReactNavigation} from 'rn-pendo-sdk'; // import {NavigationContainer} from '@react-navigation/native';
const NavigationSetup = () => { const routeNameRef = React.useRef();
return (
Also, I am not sure if this bit of an information would help or not but with just using NavigationContainer and having the pendo setup but without PendoNavigationContainer no errors are thrown, I am thinking if the onReady and onStateChange functions have an issue with PendoNavigationContainer
EDIT: I deleted the onReady and onStateChangeMethod and just left a reference there, and the issue still persists
@nvacheishvili Will you be able to create a small sample app (something minimal) that reproduce the issue and we will debug it on our side?
@MikePendo I understood that its definitely an issue with onReady functionality within pendo, because it assumes navigator object is ready when its not...
ok let us know if we can close the issue
It's likely worth investigating further, as I suspect others may encounter this issue as well.
I devised a solution by leveraging the navigation reference within the definition of a component that yields a navigation component, like Stack, for instance.
The challenge arose because we employed useEffect hooks within the component. This approach works seamlessly when the component resides inside a NavigationContainer. However, complications arise when it is placed within a PendoNavigationContainer as I think it calls onReady function too early, when the navigation object is actually not available.
Here's an example of the cause of the issue:
import {navigate} from './NavigationService';
// where NavigationService contains the following:
// import {createNavigationContainerRef} from '@react-navigation/native';
// export const navigationRef = createNavigationContainerRef();
//
// export function navigate(name, params) {
// navigationRef.current?.navigate(name, params);
// }
const NotAuthenticated = () => {
const dispatch = useDispatch();
const isConnected = useSelector(state => state.app.isConnected);
const isLoggedIn = useSelector(state => state.user.isLoggedIn);
const user = useSelector(state => state.user.user);
const [hasPin, setHasPin] = useState(null);
const [isTokenValid, setIsTokenValid] = useState(false);
useEffect(() => {
if (!isConnected) {
checkPin();
return;
}
if (isLoggedIn) {
if (user?.mfaStatus === 'Pending') {
return navigate(Routes.MFARegistration);
}
if (user?.mfaStatus === 'Enabled') {
return navigate(Routes.MFAVerification);
}
} else {
checkPin();
}
}, [isLoggedIn, user.mfaStatus, isConnected]);
return (
<Stack.Navigator
initialRouteName={
isTokenValid && hasPin ? Routes.PinLogin : Routes.LogIn
}>
<Stack.Screen
name={Routes.ChangeAccount}
component={ChangeAccount}
options={{
header: () => null,
gestureEnabled: false,
}}
/>
<Stack.Screen
name={Routes.LogIn}
component={LogIn}
options={loginHeader}
/>
<Stack.Screen
name={Routes.MFARegistration}
component={MFARegistration}
options={{
header: () => null,
gestureEnabled: false,
}}
/>
<Stack.Screen
name={Routes.MFAVerification}
component={MFAVerification}
options={{
header: () => null,
gestureEnabled: false,
}}
/>
<Stack.Screen
options={{
header: () => null,
}}
name={Routes.PinLogin}
component={PinLogin}
/>
<Stack.Screen
options={{
header: () => null,
}}
name={Routes.QaTestSetup}
component={QaTestSetup}
/>
</Stack.Navigator>
);
};
export default NotAuthenticated;
@nvacheishvili Can you please submit a support ticket to Pendo and we can schedule a zoom call?
sure, I'll look into that - thank you!
@nvacheishvili I have a beta version for us to test once a zoom call is scheduled.
Hi @nvacheishvili, did you submit an internal ticket so we can instantiate a call to test the solution?
Hey @nvacheishvili Closing this ticket due to inactivity. If a support ticket is filed, we can schedule a call to test the beta version.
Hi @shlomipendo @udilevin is there any update on this ticket? I encountered the same thing
@vickyfuzstaffing Hey Are you using our latest version (3.3.0 was released last week) I suggest checking if it reproduces with it, and if it is, please open a support ticket with all relevant details so our team can look into it.
Hi @shlomipendo. Yes I encountered it when I try to migrate Pendo SDK from 2.22.2 to 3.3.0. It is reproducible, the onReady function would always throw a undefined error. How do I and where should I open a support ticket?
The 'navigation' object hasn't been initialized yet, solution that was verified:
Platform + Version IOS 17.2 and others
SDK Version 3.1.1
Framework React Native using React Navigation
Describe the bug App crashes because Pendo navigation tries to use navigation object when its not initialized.
Expected behavior A clear and concise description of what you expected to happen.
Logs [rn-pendo-sdk] React Navigation Init. INFO [rn-pendo-sdk] React Navigation Init. INFO [rn-pendo-sdk] React Navigation Init. The 'navigation' object hasn't been initialized yet. This might happen if you don't have a navigator mounted, or if the navigator hasn't finished mounting. See https://reactnavigation.org/docs/navigating-without-navigation-prop#handling-initialization for more details.
Sample Code
Additional context Add any other context about the problem here.