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

Methods missing from innerRef

Open FraserHamilton opened this issue 4 years ago • 4 comments

The approach used in the documentation returns a reference in which this.scroll.props results in undefined meaning that we cannot use the scrollToPosition, scrollIntoView or, getScrollResponder methods.

scrollToEnd however can in fact be accessed directly from the reference i.e this.scroll.scrollToEnd()

FraserHamilton avatar Oct 17 '20 23:10 FraserHamilton

I found a little workaround. So instead of this:

const myRef = useRef(null);

useEffect(() => {
  myRef.current.props.scrollToPosition(x, y, true);
}, [x, y])

return (
  <KeyboardAwareScrollView innerRef={myRef} />
);

You can use

const myRef = useRef(null);

useEffect(() => {
  myRef.current.scrollToPosition(x, y, true);
}, [x, y])

return (
  <KeyboardAwareScrollView ref={myRef} />
);

However it's not documented so I have no clue what's going to be supported in the future

peternoordijk avatar Oct 20 '20 10:10 peternoordijk

I have the same issue

caogenyin avatar Nov 17 '20 09:11 caogenyin

I have the same issue when using scrollToIndex in KeyboardAwareFlatList.

knycornelius avatar Nov 30 '20 09:11 knycornelius

Biggest problem is TypeScript yells about: Property 'scrollIntoView' does not exist on type 'KeyboardAwareScrollView'.

tonycoco avatar Feb 23 '21 23:02 tonycoco