Skip to content
Discussion options

You must be logged in to vote

It seems that you are encountering an issue with using createRef for the scrollToIndex method in React Native, but useRef works well with it.

In React Native, the createRef function creates a ref that can be used to access DOM elements or components. However, it may not work as expected with certain methods or properties of third-party libraries.

To resolve this issue, you can continue using useRef instead of createRef. Here's how you can modify your code:

const flatListRef = React.useRef();

<Animated.FlatList ref={flatListRef} />

With this change, you can now use flatListRef.current.scrollToIndex without any issues.

Please make sure that you have the necessary versions of React Native a…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@NguyenHoangMinhkkkk
Comment options

@NguyenHoangMinhkkkk
Comment options

@tjzel
Comment options

Comment options

You must be logged in to vote
2 replies
@NguyenHoangMinhkkkk
Comment options

@tjzel
Comment options

Answer selected by NguyenHoangMinhkkkk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants