react-native-keyboard-aware-scroll-view: responder.scrollResponderScrollTo is not a function

Today i have upgraded to RN 0.65.1 and got this error.

TypeError: responder.scrollResponderScrollTo is not a function. (In 'responder.scrollResponderScrollTo({
            x: x,
            y: y,
            animated: animated
          })', 'responder.scrollResponderScrollTo' is undefined)

Lib version: "react-native-keyboard-aware-scroll-view": "^0.9.4",

The error pointed to this line: https://github.com/APSL/react-native-keyboard-aware-scroll-view/blob/master/lib/KeyboardAwareHOC.js#L276

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 19 (1 by maintainers)

Most upvoted comments

the issue persist in RN66.3

On RN 66.3 I added the following dependency in the package.json of my project and it worked:

"resolutions": {
  "native-base/@codler/react-native-keyboard-aware-scroll-view": "2.0.0"
},

Note: I am using native-base.

I have forked the repo to fix this issue.

npm i @codler/react-native-keyboard-aware-scroll-view

Issue is persistent in RN68

try this one: "react-native-keyboard-aware-scroll-view": "github:APSL/react-native-keyboard-aware-scroll-view#pull/501/head",

Issue resolved with latest version react-native-keyboard-aware-scroll-view: 0.9.5

overrides worked for me on RN 71, put it in package.json I was using native-base, maybe it won’t work for one’s who is using keyboard aware package directly

"overrides": {
    "native-base": {
      "@codler/react-native-keyboard-aware-scroll-view": "2.0.1"
    }
  }

removed node_modules and re-installed packages using npm install, and crash went away

Update the following code in the /node_modules/@codler/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js file line number 244.

`scrollToPosition = (x: number, y: number, animated: boolean = true) => { const responder = this.getScrollResponder() if (!responder) { return } if (responder.scrollResponderScrollTo) { // React Native < 0.65 responder.scrollResponderScrollTo({ x, y, animated }) } else if (responder.scrollTo) { // React Native >= 0.65 responder.scrollTo({ x, y, animated }) } // responder && responder.scrollResponderScrollTo({ x, y, animated }) }

scrollToEnd = (animated?: boolean = true) => { const responder = this.getScrollResponder() if (!responder) { return } if (responder.scrollResponderScrollTo) { // React Native < 0.65 responder.scrollResponderScrollTo({ x, y, animated }) } else if (responder.scrollTo) { // React Native >= 0.65 responder.scrollTo({ x, y, animated }) } // responder && responder.scrollResponderScrollToEnd({ animated }) }`

Above Worked for me! I was use older version of native-base “^2.15.2” with latest react native version “0.72.6”. I don’t where that codler came from but this solved my issue.

@Seunope @alishah514 This issue occurs only if we are using native base?

 scrollToPosition = (x: number, y: number, animated: boolean = true) => {
    const responder = this.getScrollResponder()
    if (!responder) {
      return
    }
    if (responder.scrollResponderScrollTo) {
      // React Native < 0.65
      responder.scrollResponderScrollTo({ x, y, animated })
      } else if (responder.scrollTo) {
      // React Native >= 0.65
      responder.scrollTo({ x, y, animated })
      }
      // responder && responder.scrollResponderScrollTo({ x, y, animated })
    }
  
    scrollToEnd = (animated?: boolean = true) => {
    const responder = this.getScrollResponder()
    if (!responder) {
     return
    }
    if (responder.scrollResponderScrollTo) {
      // React Native < 0.65
      responder.scrollResponderScrollTo({ x, y, animated })
      } else if (responder.scrollTo) {
      // React Native >= 0.65
      responder.scrollTo({ x, y, animated })
    }
    // responder && responder.scrollResponderScrollToEnd({ animated })
}

@alishah514 solution worked. I arranged the text for proper visualization. I am using native-base: 2.13.15, react-native: 0.72.6

Facing issue with RN 68 and native base.