react-native-keyboard-aware-scroll-view icon indicating copy to clipboard operation
react-native-keyboard-aware-scroll-view copied to clipboard

react-native 0.63 scrollIntoView of undefined

Open yasaricli opened this issue 4 years ago • 4 comments

When I run scrollToEnd in version 0.63, I get the error scrollIntoView of undefined.

also now scroll.props.scrollToEnd gives an error. Because there are no props.

this.scroll.props.scrollToEnd(); // Change to this.scroll.scrollToEnd();

Warning:

TypeError: Cannot read property 'scrollIntoView' of undefined

this is a warning But it doesn't scroll down.

Thanks.

yasaricli avatar Sep 02 '20 09:09 yasaricli

Hi,

Any updates on this ?

Thanks!!

Foskas avatar Oct 22 '20 12:10 Foskas

@Foskas , after working around, here is my solution how can call these functions scrollToEnd, scrollIntoView,.. for functional component

let scrollProps;
<KeyboardAwareScrollView
      innerRef={(ref) => {
        scrollProps = ref._internalFiberInstanceHandleDEV.memoizedProps;
      }}
/>
const _scrollToInput = (reactNode: ReactNode) => {
   // 200 is extra height after scrolling to component
    scrollProps.scrollToFocusedInput(reactNode, 200);
  };
<TextInput  onFocus={(event) => _scrollToInput(findNodeHandle(event.target))} />

nhatndm avatar Dec 06 '20 00:12 nhatndm

@nhatndm I was able to achieve this in more accurate way:

<KeyboardAwareScrollView
      innerRef={(ref) => { this.scrollView = ref.getScrollResponder(); }}
/>
const _scrollToInput = (reactNode: ReactNode) => {
     this.scrollView.props.scrollToFocusedInput(inputNode, 200);
};

olegmilan avatar Feb 03 '21 08:02 olegmilan

@olegmilan I modified this to allow for instance removal:

<KeyboardAwareScrollView
      innerRef={(ref) => { this.scrollView = ref ? ref.getScrollResponder() : null; }}
/>

arstropica avatar Jul 28 '21 21:07 arstropica