react-native-safe-area-context icon indicating copy to clipboard operation
react-native-safe-area-context copied to clipboard

insets at startup being null & not rendering any children causes "freeze" at startup (iOS)

Open breezertwo opened this issue 3 years ago • 0 comments

We encountered an issue with this package. At app start the app seems to crash/freeze and nothing happens, with the splash screen not disappearing. After some debugging I found out that the rest of the app isn't even loading, thus the never hidden splashscreen.

This part of SafeAreaContext.tsx seems to be the faulty area:

{insets != null ? (
   <SafeAreaFrameContext.Provider value={frame}>
       <SafeAreaInsetsContext.Provider value={insets}>
           {children}
       </SafeAreaInsetsContext.Provider>
   </SafeAreaFrameContext.Provider>
) : null}

The hook const parentInsets = useParentSafeAreaInsets() does not always deliver a value. Therefore insets being null and no children are rendered. For some other reason onInsetsChange seem not to update the insets at a later point.

For a workaround I am now providing initialMetrics via prop but your own documentation states: You cannot do this if your provider remounts, or you are using react-native-navigation. The latter is the case.

Any info or help with this issue would be awesome.

breezertwo avatar Jun 15 '22 07:06 breezertwo