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

Flicker caused by SafeAreaInsetsContext

Open AKclown opened this issue 4 years ago • 5 comments

Scenes: When I use SafeAreaInsetsContext.Consumer to deal with safe screen issues. When my application enters the task management interface, it will flicker when it comes back。

reason: Can't get the value of insets?.top in time

Source code:

<SafeAreaInsetsContext.Consumer> {insets => <View style={{ flex: 1, // Delayed acquisition paddingTop: insets?.top ?? 0, backgroundColor: '#fff', overflow: 'hidden' }}> // main content </View> } </SafeAreaInsetsContext.Consumer>

How to solve it? thanks

AKclown avatar Jan 31 '21 05:01 AKclown

I am experiencing this issue as well. @AKclown did you find a solution?

omer921 avatar Mar 08 '21 02:03 omer921

I get a very noticeable flicker from using SafeAreaView with edges={['top']}. Is this expected? I'm a bit confused. I have the provider at the root of my app too.

nandorojo avatar Apr 15 '21 23:04 nandorojo

I am also seeing this issue (in the context of supplying a custom header component to a screen in React Navigation v6). Strangely, despite it going against the performance recommendations in this project's readme, I found the following comment helpful. Using useSafeAreaInsets and manually applying the padding to my custom header does not [so far] show the same flicker.

cwhenderson20 avatar Apr 26 '21 23:04 cwhenderson20

Is it still a problem? Is it worked on or the issue is detected?

Morritz avatar May 26 '21 20:05 Morritz

Getting this issue with edges={['bottom']}. It seems to happen specifically when there is an immediate rerender of the screen. I just add a setTimeout(0, ()=>{//dostuff}) as a hack to fix it but it's pretty frustrating. Idk why SafeAreaView can't just have the correct padding the first time it renders. I even set initialWindowMetrics on the provider.

iway1 avatar Dec 13 '21 21:12 iway1

This is documented in the readme

jacobp100 avatar Jan 19 '23 16:01 jacobp100