Skip to content

Commit d5146ca

Browse files
authored
Fix warning due to calling getNode() #484 from APSL/fix-getNode-warning
* fix getNode() warning * better conditions * fix import * lint error
1 parent d96d2c1 commit d5146ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/KeyboardAwareHOC.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ const ScrollIntoViewDefaultOptions: KeyboardAwareHOCOptions = {
128128
// Sometimes the ref you get is a ref to a wrapped view (ex: Animated.ScrollView)
129129
// We need access to the imperative API of a real native ScrollView so we need extraction logic
130130
extractNativeRef: (ref: Object) => {
131-
// getNode() permit to support Animated.ScrollView automatically
131+
// getNode() permit to support Animated.ScrollView automatically, but is deprecated since RN 0.62
132132
// see https://github.com/facebook/react-native/issues/19650
133133
// see https://stackoverflow.com/questions/42051368/scrollto-is-undefined-on-animated-scrollview/48786374
134-
if (ref.getNode) {
134+
// see https://github.com/facebook/react-native/commit/66e72bb4e00aafbcb9f450ed5db261d98f99f82a
135+
const shouldCallGetNode = !Platform.constants || (Platform.constants.reactNativeVersion.major === 0 && Platform.constants.reactNativeVersion.minor < 62)
136+
if (ref.getNode && shouldCallGetNode) {
135137
return ref.getNode()
136138
} else {
137139
return ref

0 commit comments

Comments
 (0)