fix: apply monkey patch before StatusBar
updates
#744
Merged
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
Execute monkey-patch applying earlier than
StatusBar
modifications.💡 Motivation and Context
It happens when
KeyboardProvider
had direct child asStatusBar
- and such thing can happen inexpo-router
, for example: https://github.com/expo/expo/blob/5f40a80019bb6b892eda94dd244fdc0df8880ccb/packages/expo-router/src/ExpoRoot.tsx#L57To prevent this problem I'm executing monkey patch applying in "layout effect" instead of plain "effect". This gives me a precious time and an ability to apply patch earlier and thus re-direct a call to my module.
And if we dig a little bit deeper. When
KeyboardProvider
gets mounted theuseLayoutEffect
will be fired after component mount. On contrastStatusBar
will try to change its properties incomponentDidMount
. And technicallycomponentDidMount
will be executed first (beforeuseLayoutEffect
). ButStatusBar
schedules update viasetImmediate
andsetImmediate
will execute its callback afteruseLayoutEffect
, so this fix should work 🙂Closes #708 #587
📢 Changelog
Android
StatusBar
module (ifKeyboardProvider
andStatusBar
were mounted simultaneously).🤔 How Has This Been Tested?
Tested manually in https://github.com/NyoriK/keyboard-controller-test-project
📸 Screenshots (if appropriate):
Screen.Recording.2024-12-23.at.15.41.19.mov
📝 Checklist