I'm trying to pass a ref to a component with a similar approach to the following code block, but the current
value always returns undefined
. This approach works fine with a plain FlatList
from react-native, however it doesn't work once I'm using either an Animated.FlatList
or an Animated.createAnimatedComponent(FlatList)
:
const Parent = () => {
const flatListRef = useRef();
useEffect(() => {
console.log(flatListRef.current) // undefined
})
return (
<View>
<Child ref={flatListRef} />
</View>
)
}
const Child = React.forwardRef((props, ref) => {
return (
<Animated.FlatList
ref={ref}
/>
)
})