pendo-io / pendo-mobile-sdk

Pendo captures product usage data, gathers user feedback, and lets you communicate in-app to onboard, educate, and guide users to value
https://www.pendo.io
Other
58 stars 2 forks source link

WithPendoReactNavigation Typescript Issues #46

Closed bhandanyan-nomad closed 1 year ago

bhandanyan-nomad commented 1 year ago

Example app code:

const PendoNavigationContainer = WithPendoReactNavigation(NavigationContainer);
...
return (
    <PendoNavigationContainer
      ...
      linking={linkingConfig}
      ref={navigationRef}
      ... >
      ...
    </PendoNavigationContainer>
);

I am getting typescript errors on both the "linking" and "ref" props: linking: Type 'LinkingOptions<RootStackParamList> | undefined' is not assignable to type 'LinkingOptions<{}> | undefined'. ref: Type 'NavigationContainerRefWithCurrent<RootParamList>' is not assignable to type 'Ref<NavigationContainerRef<{}>> | undefined'.

Both seem to be related to my app's param list object, which I defined following react navigation's recommendation here. I have yet to find a way to tell Pendo to use my param list, is it possible to do so with the current package?

Package versions:

"rn-pendo-sdk": "2.21.2",
"@react-navigation/native": "6.0.8",
bhandanyan-nomad commented 1 year ago

My workaround for now is:

const PendoNavigationContainer = WithPendoReactNavigation(
  NavigationContainer,
) as typeof NavigationContainer;
MikePendo commented 1 year ago

@bhandanyan-nomad Strange, I don't see such error for instance my sample code:

const navigationRef = useNavigationContainerRef();//OR createNavigationContainerRef();
    return (
        <BottomSheetContext.Provider
            <SafeAreaProvider>
                <PendoNavigationContainer
                ref={navigationRef}
                >
                    <GestureHandlerRootView style={styles.container}>
                        {getStackNavigator()}
                        <PrimaryBottomSheet />
                    </GestureHandlerRootView>
                </PendoNavigationContainer>
            </SafeAreaProvider>
        </BottomSheetContext.Provider>
    );

How do u initialize your navigationRef? "@react-navigation/native": "^6.0.10" I also changed to your exact version 6.0.8 but still don't see the error

MikePendo commented 1 year ago

@bhandanyan-nomad any progress on it? Will it be ok if we close your ticket?

MikePendo commented 1 year ago

@bhandanyan-nomad I am closing the issue, feel free to ping us.

bhandanyan-nomad commented 1 year ago
const navigationRef = useNavigationContainerRef();

nothing special there.

Have you specified global navigation param types as described here? This seems to be what is causing my issue, because as soon as I comment out the entire declare global block those errors disappear.