Commit 19371d8
authored
fix: apply monkey patch before
## 📜 Description
Execute monkey-patch applying earlier than `StatusBar` modifications.
## 💡 Motivation and Context
It happens when `KeyboardProvider` had direct child as `StatusBar` - and
such thing can happen in `expo-router`, for example:
https://github.com/expo/expo/blob/5f40a80019bb6b892eda94dd244fdc0df8880ccb/packages/expo-router/src/ExpoRoot.tsx#L57
To 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
the `useLayoutEffect` will be fired after component mount. On contrast
`StatusBar` will try to change its properties in `componentDidMount`.
And technically `componentDidMount` will be executed first (before
`useLayoutEffect`). But `StatusBar` schedules update via `setImmediate`
and `setImmediate` will execute its callback after `useLayoutEffect`, so
this fix should work 🙂
Closes
#708
#587
## 📢 Changelog
### Android
- apply monkey patch in layout effect to be sure monkey patch can be
applied earlier than first call to `StatusBar` module (if
`KeyboardProvider` and `StatusBar` were mounted simultaneously).
## 🤔 How Has This Been Tested?
Tested manually in
https://github.com/NyoriK/keyboard-controller-test-project
## 📸 Screenshots (if appropriate):
https://github.com/user-attachments/assets/6e259ffe-de59-46a6-b9a6-26de05698b06
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changedStatusBar updates (#744)1 parent 0ce68ed commit 19371d8
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
196 | | - | |
| 195 | + | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
0 commit comments