react-native-flatlist

Flatlist inside Scrollview onEndReached

我们两清 提交于 2019-12-11 02:22:23
问题 I have a Flatlist inside animated ScrollView. Flatlist has onEndReached implemented with threshold set to 0.5. The problem I am facing is onEndReached keeps triggering without even scrolling. I have an article view with a body. I want to load the comments when user reaches the end of article body, and onEndReached should only trigger when comments end is reached. Please suggest if I should deal with the problem differently, I am stuck on this for quite a while. 来源: https://stackoverflow.com

React-Native FlatList not re-rendering with custom renderItem

倾然丶 夕夏残阳落幕 提交于 2019-12-10 23:07:39
问题 I have a FlatList that works as expected when using a plain old <Text> tag, but when using a custom Component inside renderItem, the FlatList will not re-render when changing this.state.dayOfYear . On app load, when I set this.state.dayOfYear , it loads properly. But when I change state again, it will not change the FlatList. FlatList Code <FlatList style={{flex: 1}} extraData={this.state} data={reading_data[this.state.dayOfYear]} renderItem={({item}) => <DayRow content={item}/>} //does not

React-native: FlatList get refs to scroll

隐身守侯 提交于 2019-12-10 17:54:40
问题 I'm currently building an app with react native: this is my flatlist: <FlatList ref={"myFlatList"} data={data} keyExtractor={this._keyExtractor} renderItem={this._renderItem} /> In this function I want to scroll to a specific index: _enableTVEventHandler() { this._tvEventHandler = new TVEventHandler(); this._tvEventHandler.enable(this, function(cmp, evt) { this.refs["myFlatList"].scrollToIndex({viewPosition: 0.5, index: 2}); }.bind(this)); } But I have an error: Cannot read property

How to efficiently render different views in FlatList

 ̄綄美尐妖づ 提交于 2019-12-10 11:59:03
问题 I am creating a calendar component that contains 2 Views with FlatList . Each View is associated with a different data source. Specifically, View 1 will display all days in a month where View 2 will display all days in a week. Link to video demo, button of year is for view switching For simplicity, each month/week view is represented by a date as an array item in a bigger array. For example, each item in the month array is a unique data in a month. An array of size 12 will have 12 unique

wants to autoscroll flatlist in react native

▼魔方 西西 提交于 2019-12-10 11:35:39
问题 I am trying to auto scroll my flatlist but when I run my code I cannot scroll auto and if I want to manual scroll it comes to index 0 after every 5 seconds .. here is my all code of flat list and its refs function in constructor this.flatList1=null; And in componentwillMount componentWillMount(){ setInterval(()=>{ if(this.flatList1!==null){ this.flatList1.scrollToOffset({ offset: 1 }) } }, 5000); } <FlatList horizontal data={this.state.getallvideos} ref={flatList1 => { this.flatList1 =

React-Native FlatList performance problems with large list

懵懂的女人 提交于 2019-12-09 09:53:08
问题 My code gets Json data to an array lists the data using a FlatList . It looks like a phonebook photo and text in a row. Here is My code: renderItem = ({ item }) => ( <ListItem title={item.username} avatar={{ uri: item.photo }} /> ) render() { console.log(this.state.myData); return ( <View style={styles.container}> <FlatList data={this.state.myData} renderItem={this.renderItem} /> </View> ); } Its works and I get the output, but the performance is slow. Rendering takes approximately 10 seconds

How to get currently visible index in RN flat list

大兔子大兔子 提交于 2019-12-09 04:35:33
问题 I have a horizontal flat list where each item is width:300 All I am trying to do is to get index of currently visible item. <FlatList onScroll={(e) => this.handleScroll(e)} horizontal={true} data={this.state.data} renderItem... Tried this: handleScroll(event) { let index = Math.ceil( event.nativeEvent.contentOffset.x / 300 ); And something like this: handleScroll(event) { let contentOffset = event.nativeEvent.contentOffset; let index = Math.floor(contentOffset.x / 300); but nothing is

wants to autoscroll flatlist in react native

橙三吉。 提交于 2019-12-08 17:35:29
I am trying to auto scroll my flatlist but when I run my code I cannot scroll auto and if I want to manual scroll it comes to index 0 after every 5 seconds .. here is my all code of flat list and its refs function in constructor this.flatList1=null; And in componentwillMount componentWillMount(){ setInterval(()=>{ if(this.flatList1!==null){ this.flatList1.scrollToOffset({ offset: 1 }) } }, 5000); } <FlatList horizontal data={this.state.getallvideos} ref={flatList1 => { this.flatList1 = flatList1 }} renderItem={({item}) => <TouchableOpacity onPress={this.playvideoinnetpage.bind(this,item.vd

FlatList onEndReached being called multiple times

余生颓废 提交于 2019-12-08 15:19:15
问题 I'm making a react native project where user can search images using Flickr API, Everything else is working fine but the problem i'm having while implementing pagination. I have used FlatList's onEndReached to detect when user has scrolled to the end on the list, but the problem is onEndReached is being called multiple times(including one during the first render). I have even disabled bounce as said here but it's still being called more than once export default class BrowserHome extends React

Highlight a selected item in React-Native FlatList

时间秒杀一切 提交于 2019-12-08 14:42:12
问题 I put together a simple React-native application to gets data from a remote service, loads it in a FlatList. When a user taps on an item, it should be highlighted and selection should be retained. I am sure such a trivial operation should not be difficult. I am not sure what I am missing. import React, { Component } from 'react'; import { StyleSheet, Text, View, FlatList, ActivityIndicator, Image, TouchableOpacity, } from 'react-native'; export default class BasicFlatList extends Component {