Skip to content

Commit

Permalink
Fix warning due to calling getNode() #484 from APSL/fix-getNode-warning
Browse files Browse the repository at this point in the history
* fix getNode() warning

* better conditions

* fix import

* lint error
  • Loading branch information
slorber authored Apr 29, 2021
1 parent d96d2c1 commit d5146ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/KeyboardAwareHOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,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
Expand Down

0 comments on commit d5146ca

Please sign in to comment.