appandflow / appandflow/react-native-safe-area-context

useSafeAreaInsets emits too many results during device rotation

オープン
#172 コメント 10 件 リアクション 13 件 担当者 0 名 GitHub で見る
help wanted
主要言語
TypeScript
スター
2.8k
フォーク
258
平均マージ
3日 1時間
マージ済み PR(30日)
2

説明

Because of the device performance issue, the repeated emission of the same insets or useless emission from `useSafeAreaInsets` should be skipped.

When I rotated my device with `iPhone X`, the console printed out like the following.

## AS-IS

```
[Tue Jan 26 2021 11:40:03.498] LOG openFullScreen
[Tue Jan 26 2021 11:40:03.512] LOG {"bottom": 34, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:04.220] LOG {"bottom": 21, "left": 44, "right": 0, "top": 0}
[Tue Jan 26 2021 11:40:04.267] LOG {"bottom": 21, "left": 44, "right": 0, "top": 0}
[Tue Jan 26 2021 11:40:04.644] LOG {"bottom": 21, "left": 44, "right": 0, "top": 0}
[Tue Jan 26 2021 11:40:04.930] LOG {"bottom": 0, "left": 0, "right": 0, "top": 0}
[Tue Jan 26 2021 11:40:05.251] LOG {"bottom": 0, "left": 44, "right": 0, "top": 0}
[Tue Jan 26 2021 11:40:05.558] LOG {"bottom": 21, "left": 44, "right": 44, "top": 0}
[Tue Jan 26 2021 11:40:05.827] LOG {"bottom": 21, "left": 44, "right": 44, "top": 0}
```

```
[Tue Jan 26 2021 11:40:08.221] LOG closeFullScreen
[Tue Jan 26 2021 11:40:08.325] LOG {"bottom": 21, "left": 44, "right": 44, "top": 0}
[Tue Jan 26 2021 11:40:08.491] LOG {"bottom": 0, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:08.793] LOG {"bottom": 0, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:09.234] LOG {"bottom": 0, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:09.394] LOG {"bottom": 0, "left": 0, "right": 0, "top": 0}
[Tue Jan 26 2021 11:40:09.677] LOG {"bottom": 0, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:09.956] LOG {"bottom": 34, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:10.364] LOG {"bottom": 34, "left": 0, "right": 0, "top": 44}
```

The 6 emissions of the processing are useless and cause performance issues because every layout of components is re-calculated with each inset values.

## TO-BE

```
[Tue Jan 26 2021 11:40:03.498] LOG openFullScreen
[Tue Jan 26 2021 11:40:03.512] LOG {"bottom": 34, "left": 0, "right": 0, "top": 44}
[Tue Jan 26 2021 11:40:05.827] LOG {"bottom": 21, "left": 44, "right": 44, "top": 0}
```

```
[Tue Jan 26 2021 11:40:08.221] LOG closeFullScreen
[Tue Jan 26 2021 11:40:08.325] LOG {"bottom": 21, "left": 44, "right": 44, "top": 0}
[Tue Jan 26 2021 11:40:10.364] LOG {"bottom": 34, "left": 0, "right": 0, "top": 44}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。