heap / react-native-heap

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

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

Closed TuurDutoit closed 1 year 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 1 year ago

I plan to include this in a release this week.