P
P
pcdesign2019-05-11 20:46:04
React Native
pcdesign, 2019-05-11 20:46:04

How to make "bookmarks" in FlatList?

There is an application - a collection of quotes.
The user reads quotes from Socrates. For example, he stopped at the 101st quote out of 800.
How can he bookmark the place where he left off so as not to start reading from scratch?

<FlatList
  data={[{key: 'a'}, {key: 'b'}]}
  renderItem={({item}) => <Text>{item.key}</Text>}
/>

I understand that using AsyncStorage, you can store the ID of the quote on which the user pointed to the "bookmarks".
But how to scroll to this most necessary bookmark?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2019-05-13
@pcdesign

in the documentation for FlatList there are methods
scrollToEnd
scrollToIndex
scrollToItem
scrollToOffset
with which you can implement bookmarks and so on.
https://facebook.github.io/react-native/docs/flatlist

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question