heap / react-native-heap

A React Native integration for Heap
MIT License
81 stars 36 forks source link

[HEAP-49278] Fix capture when React Navigation rootState is null #412

Closed TuurDutoit closed 12 months ago

TuurDutoit commented 1 year ago

Description

Fixes #366

In some cases, react-navigation's getRootState() can return undefined, as documented here and here. This was being passed to getActiveRouteProps(), causing it to throw: Cannot read property 'routes' of undefined

Test Plan

We applied this change as a patch in our app first, and confirmed it removes the error and successfully sends events. I also added some unit tests for this behaviour here.

Checklist

bnickel commented 12 months ago

I plan to include this in a release this week.