From 7b729b7f196df4b220eb6f9431fbd76978d962b1 Mon Sep 17 00:00:00 2001 From: Gertjan Reynaert Date: Tue, 28 Sep 2021 16:23:08 +0200 Subject: [PATCH 1/2] Update KeyboardAwareHOC.js In our test suite `Platform.constants` is an empty object. This was making the previous `!Platform.constants` check pass, but caused a crash when trying to access `major` on `reactNativeVersion`. This fix correctly checks if `reactNativeVersion` is present and is an object to avoid this issue. --- lib/KeyboardAwareHOC.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 3d94b82..f86d760 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -132,7 +132,11 @@ const ScrollIntoViewDefaultOptions: KeyboardAwareHOCOptions = { // see https://github.com/facebook/react-native/issues/19650 // see https://stackoverflow.com/questions/42051368/scrollto-is-undefined-on-animated-scrollview/48786374 // see https://github.com/facebook/react-native/commit/66e72bb4e00aafbcb9f450ed5db261d98f99f82a - const shouldCallGetNode = !Platform.constants || (Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62) + const shouldCallGetNode = + typeof Platform?.constants?.reactNativeVersion === 'Object' && + Platform.constants.reactNativeVersion.major === 0 && + Platform.constants.reactNativeVersion.minor < 62; + if (ref.getNode && shouldCallGetNode) { return ref.getNode() } else { From 532e5be36d81da748b742a1bb29f920855231d43 Mon Sep 17 00:00:00 2001 From: Gertjan Reynaert Date: Tue, 28 Sep 2021 16:40:51 +0200 Subject: [PATCH 2/2] Fix typo --- lib/KeyboardAwareHOC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index f86d760..2f10885 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -133,7 +133,7 @@ const ScrollIntoViewDefaultOptions: KeyboardAwareHOCOptions = { // see https://stackoverflow.com/questions/42051368/scrollto-is-undefined-on-animated-scrollview/48786374 // see https://github.com/facebook/react-native/commit/66e72bb4e00aafbcb9f450ed5db261d98f99f82a const shouldCallGetNode = - typeof Platform?.constants?.reactNativeVersion === 'Object' && + typeof Platform?.constants?.reactNativeVersion === 'object' && Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62;