react-native-flatlist

how to align elements horizontally in flatlist react native?

∥☆過路亽.° 提交于 2021-01-29 08:12:46
问题 I would like to achieve this: https://imgur.com/a/9aI1HJk My Result: https://imgur.com/a/qATfSk1 I'm new I don't know very well how to achieve that alignment, any help is appreciated :) My code: <View style={styles.calendar}> <View style={styles.calendar_week}> <FlatList data={daysWeek} keyExtractor={(item) => item.id} numColumns={7} renderItem={({item}) => ( <Text style={styles.dayWeek}>{item.day}</Text> )} /> </View> <View style={styles.calendar_week}> <FlatList data={days} style={styles

React Native render FlatList conditional

两盒软妹~` 提交于 2021-01-28 08:10:31
问题 I have a question regarding React Native FlatList. I have a FlatList that gets my dataZ state as the data prop - dataZ is an Array that gets filled in by my fetchcall. The response of my fetch call looks like this: [ { "activitydate": "2019-08-01T22:00:00.000Z", "phaseid": 7667, "time": 360, "userid": 138, "zkub": " " }, { "activitydate": "2019-08-04T22:00:00.000Z", "phaseid": null, "time": 456, "userid": 138, "zkub": "K" }, { "activitydate": "2019-08-05T22:00:00.000Z", "phaseid": null, "time

React Native | Rerender Flatlist

烂漫一生 提交于 2021-01-28 04:49:45
问题 I have a list: data. Then when I update the list, it renders all the elements again. For example, let's say there are 10 items. One of these has changed. 10 items are rendering again. But since 9 of them are the same, they should not be rendered again. How can I do? const Item =({item}) => ( <Text>{item.name}</Text> ) const List = () => { const [data, setData] = useState([..]); return ( <FlatList data={data} renderItem = {Item} > )} export default List; 回答1: You have to use extraData prop of

React Native FlatList with object

早过忘川 提交于 2021-01-22 05:58:09
问题 I want to render object with React Native's FlatiList but this component doesn't return the expected result. My dictionary is like this: Object { "Lisa.Sky": Object { "name": "Lisa", "surname": "Sky", "age": 21, "sex": female }, "Thomas.Prat": Object { "name": "Thomas", "surname": "Prat", "age": 33, "sex": male }, "Paul.Sing": Object { "name": "Paul", "surname": "Sing", "age": 88, "sex": male }, "Andrew.Brown": Object { "name": "Andrew", "surname": "Brown", "age": 23, "sex": male }, } I have

FlatList Component Life Cycle Methods ScrollToIndex ScrollToEnd etc

纵饮孤独 提交于 2021-01-18 05:55:57
问题 I am using the new FlatList component and want to make use of ScrollToIndex (or ScrollToEnd ) within lifecycle methods such as componentDidMount . I have an array of let's say 100 items and I don't want to start to render at the first item but in the beginning. Let's say at the 50th item. When the FlatList is only showing one item at a time, it's working as desired with some hack as described here: https://github.com/facebook/react-native/issues/13202 componentDidMount() { let wait = new

FlatList does not rerender even if state assigned to extraData changes

╄→гoц情女王★ 提交于 2021-01-07 01:34:40
问题 I am building a Instagram clone backed by firebase and redux. I have a Profile screen in which i render the posts that the user has made. The problem with this is the posts does not get updated, I was using FlatList component and found that we need to use a extraData prop. This is my Profile.tsx (Profile screen) : import React, { useState, useEffect } from "react"; import { View, Text, StyleSheet, Image, FlatList, Alert } from "react-native"; import db, { auth } from "../../firebase"; import

How to call fetch() inside renderItem on FlatList?

て烟熏妆下的殇ゞ 提交于 2021-01-05 06:42:36
问题 I have been unable to solve this so far, I hope someone from here can help me :) The situation is as following: I load a list of users from a department using an API which returns it as JSON (this works). For each user in the JSON file, I have to fetch another JSON file containing sensor data (this does not work). I am in fact capable of getting the JSON data from the getStatus() function, but it is not correct. Because, when the FlatList is rendered, the data still has not been fetched, but

How to call fetch() inside renderItem on FlatList?

旧街凉风 提交于 2021-01-05 06:40:05
问题 I have been unable to solve this so far, I hope someone from here can help me :) The situation is as following: I load a list of users from a department using an API which returns it as JSON (this works). For each user in the JSON file, I have to fetch another JSON file containing sensor data (this does not work). I am in fact capable of getting the JSON data from the getStatus() function, but it is not correct. Because, when the FlatList is rendered, the data still has not been fetched, but

How to add load more records with Spinner in FlatList react-native (means -10 - 10 records) manually! not from using server side

三世轮回 提交于 2020-12-29 09:19:06
问题 Hi I am developing sample application based on FlatList this is my code here. Actually i showed entire records like i have 50 records to my account . But now i am displaying entire 50 records. Bur i need show 10 after adding to 10 records. But i don't know adding to FlatList. Here this is my code: <FlatList data={this.state.profiles} renderItem={({ item, index }) => this.renderCard(item, index)} keyExtractor={item => item.id} ItemSeparatorComponent={() => <Divider style={{ marginTop: 5,

How to sort flatlist in React Native?

情到浓时终转凉″ 提交于 2020-12-15 06:26:30
问题 I have data stored in a state that is shown in flatlist, I want to sort the data based on ratings. So if I click on sort button they should be sorted in ascending order and when I click again, they should be sorted in descending order. I have an array of objects stored in state, below is just a piece of data that is important. show_data_list = [{ ratings : { overall : 4, ...other stuff } } ] Is there a way I could do it, I tried using the map function which sorts array list.map((a,b) => a-b)