Detect react-native-edge-to-edge and bypass setShouldMimicIOSBehavior #219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR brings
react-native-edge-to-edge
detection toreact-native-avoid-softinput
.The future of Android is edge-to-edge, and to make the React Native developer experience seamless in this regard, the ecosystem needs to transition from “opaque system bars by default” to “edge-to-edge by default.”
To prevent library authors from implementing their own edge-to-edge solutions—which could interfere with other libraries—and because it’s not possible to reliably detect if edge-to-edge is already enabled on Android, we have collaborated with Expo to create a library that handles this functionality and is detectable using a simple helper:
react-native-is-edge-to-edge
(250 bytes minified - no gzip).This approach allows you to bypass certain options and props (in this case, it removes the need to call
setShouldMimicIOSBehavior
entirely, which is dangerous assetShouldMimicIOSBehavior(false)
currently breaks edge-to-edge).After digging a bit into your code, I think this is the only required change.
setShouldMimicIOSBehavior
callssetShouldHandleInsets
, which only callWindowCompat.setDecorFitsSystemWindows(activity.window, decorFitsSystemWindows)
(doesn't even update a module level variable or else), something already handled byreact-native-edge-to-edge
that callWindowCompat.setDecorFitsSystemWindows(activity.window, false)
immediately at app start.This will also print a warning to inform the users that calling this function is not needed anymore in such case:
PS: If you want to keep the call, I can update the TS to be:
Affected platforms