React-native-keyboard-aware-scroll-view: Compatibility with React Hook's useEffect (TypeScript)

Created on 25 Jun 2019  路  3Comments  路  Source: APSL/react-native-keyboard-aware-scroll-view

innerRef={ value => { _someRef = value } }

Above code is not possible when using React Hook's useEffect.

innerRef={ _someRef }

Whereas this causes a type error as _someRef is not a function.

Most helpful comment

const refScroll = useRef(null)

innerRef={ value => { refScroll.current = value } }

This may work

All 3 comments

const refScroll = useRef(null)

innerRef={ value => { refScroll.current = value } }

This may work

I'm having the same issue, useRef is not working, even tried suggestion above

null is not an object (evaluating refScroll.current.props)

@DrySoldier : initial value of ref is NULL, so you much check null value before access

if (refScroll.current !== null) {
 // do something with refScroll.current
}
Was this page helpful?
0 / 5 - 0 ratings