From 99b23f33e386e1414fc710c007f545660937491e Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 29 Apr 2021 18:15:26 +0200 Subject: [PATCH 1/4] fix getNode() warning --- lib/KeyboardAwareHOC.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 9710dda7..48a66c08 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -8,7 +8,8 @@ import { UIManager, TextInput, findNodeHandle, - Animated + Animated, + Platform } from 'react-native' import { isIphoneX } from 'react-native-iphone-x-helper' import type { KeyboardAwareInterface } from './KeyboardAwareInterface' @@ -128,10 +129,12 @@ const ScrollIntoViewDefaultOptions: KeyboardAwareHOCOptions = { // Sometimes the ref you get is a ref to a wrapped view (ex: Animated.ScrollView) // We need access to the imperative API of a real native ScrollView so we need extraction logic extractNativeRef: (ref: Object) => { - // getNode() permit to support Animated.ScrollView automatically + // getNode() permit to support Animated.ScrollView automatically, but is deprecated since RN 0.62 // see https://github.com/facebook/react-native/issues/19650 // see https://stackoverflow.com/questions/42051368/scrollto-is-undefined-on-animated-scrollview/48786374 - if (ref.getNode) { + // see https://github.com/facebook/react-native/commit/66e72bb4e00aafbcb9f450ed5db261d98f99f82a + const shouldCallGetNode = !Platform.constants || Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62; + if (ref.getNode && shouldCallGetNode) { return ref.getNode() } else { return ref From fcf62b32e60cb0de4b380239846271dc6a5b8de8 Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 29 Apr 2021 18:21:21 +0200 Subject: [PATCH 2/4] better conditions --- lib/KeyboardAwareHOC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 48a66c08..a854b484 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -133,7 +133,7 @@ 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 = !Platform.constants || (Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62); if (ref.getNode && shouldCallGetNode) { return ref.getNode() } else { From 7828094b9c34370978d8a0d58bca5cfa8d1cb348 Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 29 Apr 2021 18:23:23 +0200 Subject: [PATCH 3/4] fix import --- lib/KeyboardAwareHOC.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index a854b484..4b28e213 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -8,8 +8,7 @@ import { UIManager, TextInput, findNodeHandle, - Animated, - Platform + Animated } from 'react-native' import { isIphoneX } from 'react-native-iphone-x-helper' import type { KeyboardAwareInterface } from './KeyboardAwareInterface' From e33ad471a9279eb95fc1cda872bba6560f2b1bf0 Mon Sep 17 00:00:00 2001 From: slorber Date: Thu, 29 Apr 2021 18:26:34 +0200 Subject: [PATCH 4/4] lint error --- lib/KeyboardAwareHOC.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 4b28e213..3d94b824 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -132,7 +132,7 @@ 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 = !Platform.constants || (Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62) if (ref.getNode && shouldCallGetNode) { return ref.getNode() } else {