React Native - how to show a list not at the beginning of it?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



React Native - how to show a list not at the beginning of it?



I need to render a list with the user rankings
Want to mount the list showing 10 positions on the screen at a time.
And always start to show the part of the list where the user is, even if he is a the position 200 of 1000 and then the user could scroll up and down to explore the list.



Does exist a way to do it?



I'm using something like this


import React, Component from 'react';
import ListView from 'react-native';
import connect from 'react-redux';
import ListItem from './ListItem';

class LibraryList extends Component
componentWillMount()
const ds = new ListView.DataSource(
rowHasChanged: (r1, r2) => r1 !== r2
);

this.dataSource = ds.cloneWithRows(this.props.libraries);


renderRow(library)
return <ListItem library=library />;


render()
return (
<ListView
dataSource=this.dataSource
renderRow=this.renderRow
/>
);



const mapStateToProps = state =>
return libraries: state.libraries ;
;

export default connect(mapStateToProps)(LibraryList);





Could you include the code you have written so far?
– Tholle
Aug 11 at 16:22





Use FlatList or SectionList, ListView is deprecated
– Raviprakash
Aug 11 at 17:34





1 Answer
1



First of all, use a FlatList. The ListView is deprecated and the new list is much better in terms of optimization and usability.



Now for your question, the FlatList actually has a props called initialScrollIndex which allow you to decide which item you want to show at the first render



Hope it's what you're looking for!





Yes, exactly. Thank you very much. Now I'v to figure out how the getItemLayout works.
– César Cota
Aug 13 at 16:02







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered