useSafeAreaInsets emits too many results during device rotation
See original GitHub issueBecause 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 Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6
Top Results From Across the Web
th3rdwave - Bountysource
Hi, I use your module in a react-native-app, and I presume I need to mock it when I want to use it with...
Read more >SafeAreaContext - Expo Documentation
This is a more advanced use-case, and might perform worse than SafeAreaView when rotating the device. First, add SafeAreaProvider in your app root...
Read more >Virtual Pronunciation Coach Developed in React Native - Morioh
Automatically, the list of words to be practice is updated with the results. Challenge. Search: Localize a specific word to pratice:.
Read more >Ionic 4 Ignored Notch On Iphone X And 11 - ADocLib
Apple's iPhone X has a screen that covers the entire face of the ... behind the notch in landscape view even after Just...
Read more >react native safe area context Code Example
_handle.onchange (internal/fs/watchers.js:178:28) · jest watch too many open files ... how to lock device orientation using css and javascript ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Having the same issue here. Did anyone find a solution yet?
In my case, I just made native module for me. There are several files and verbose codes but If you need you can use it. These codes are written with Swift Native Module. If you need to learn how to use Swift for Native Module in RN, look my sample project, documentation.
This module reduces some ignorable event emission but not 100%
SafeArea.swift
MainViewController.swift
Appdelegate.m
Modules.m
SafeAreaModuleIOS.ts
useSafeAreaInsets.ios.ts