Skip to content

Commit ecd3bbd

Browse files
authored
fix: could not fing view for tag warning (#1379)
## 📜 Description Silent `could not fing view for tag` warning for `KeyboardAwareScrollView` (similarly how it works for `KeyboardAvoidingView` now). ## 💡 Motivation and Context This issue got introduced after #1352 (which was based on #1346) In certain cases `onLayout` may be triggered but view may be not laid out yet (if you use it with `react-native-pager` lazy). Since changes in #1352 were purely additional (we try to understand the position of element on the screen, but before these changes we always assumed we were in the top of the screen) I decided to wrap it for now in `try/catch` block. Silenting error is not a correct fix, but this is the best what we can do now - we will not spam logs when devs update the package (in #1346 we also used `catch` block), but yes, in certain cases detection of top border will not work (and it didn't work before, so it's fair enough to silent the error). Closes #1375 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### JS - handle rejected promises within `try/catch` block; ## 🤔 How Has This Been Tested? Tested via e2e tests, I didn't test changes manually because I don't have a repro. ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 38cdb43 commit ecd3bbd

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • src/components/KeyboardAwareScrollView

src/components/KeyboardAwareScrollView/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ const KeyboardAwareScrollView = forwardRef<
164164
onLayout?.(e);
165165

166166
if (handle !== null) {
167-
const { y } = await KeyboardControllerNative.viewPositionInWindow(
168-
handle,
169-
);
170-
171-
scrollViewPageY.value = y;
167+
try {
168+
const { y } = await KeyboardControllerNative.viewPositionInWindow(
169+
handle,
170+
);
171+
172+
scrollViewPageY.value = y;
173+
} catch {
174+
// ignore
175+
}
172176
}
173177
},
174178
[onLayout],

0 commit comments

Comments
 (0)