APSL / react-native-keyboard-aware-scroll-view

A ScrollView component that handles keyboard appearance and automatically scrolls to focused TextInput.
MIT License
5.27k stars 646 forks source link

responder.scrollResponderScrollTo is not a function #504

Closed luutruong closed 3 years ago

luutruong commented 3 years ago

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

luutruong commented 3 years ago

PR fix: https://github.com/APSL/react-native-keyboard-aware-scroll-view/pull/501

luutruong commented 3 years ago

Related issue: https://github.com/APSL/react-native-keyboard-aware-scroll-view/issues/494

codler commented 3 years ago

I have forked the repo to fix this issue.


npm i @codler/react-native-keyboard-aware-scroll-view
hemantasapkota commented 3 years ago

Brilliant, thanks @codler

dongdyang commented 3 years ago

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

FadiAboMsalam commented 2 years ago

the issue persist in RN66.3

DanielAraldi commented 2 years ago

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.

masudhossain commented 2 years ago

Issue is persistent in RN68

Yandamuri commented 2 years ago

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

harshmdr commented 1 year ago

Facing issue with RN 68 and native base.

Aryk commented 1 year ago

Im on 0.9.5 and still experiencing this issue occasionally, specifically after a sandbox purchase is made.

miteshdb commented 1 year ago

It is happening on RN 71 as well, using native-base

miteshdb commented 1 year ago

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

davidwinograd1 commented 1 year ago

None of these worked for me. I am using RN 0.68.7 and "react-native-keyboard-aware-scroll-view": "^0.9.5". Can someone help / was anyone able to fix it? @miteshdb @luutruong @codler @dongdyang

luutruong commented 1 year ago

None of these worked for me. I am using RN 0.68.7 and "react-native-keyboard-aware-scroll-view": "^0.9.5". Can someone help / was anyone able to fix it? @miteshdb @luutruong @codler @dongdyang

Did you try to clear cache?

alishah514 commented 10 months ago

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 commented 9 months ago
 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

Yandamuri commented 9 months ago

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

alishah514 commented 9 months ago

@Yandamuri Yes, if you look into native base's inner node modules you'll find dependency of codler/react-native-keyboard-aware-scroll-view there. That is the main reason of this issue. Plus Older Version of native base and newer react native version makes this issue.

yarelosa commented 3 months ago
 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

Are you tried to apply an patch?