Skip to content

Check the render method of 'Flatlistdemo' #25741

Closed
@keshav00001

Description

@keshav00001

image
app.js
/**

  • Sample React Native App
  • https://github.com/facebook/react-native
  • @Format
  • @flow
    */
    import React, { Component } from "react";
    import { List, ListItem } from "react-native-elements";
    import {
    SafeAreaView,
    StyleSheet,
    ScrollView,
    View,
    Text,
    FlatList ,
    StatusBar,
    } from 'react-native'

class FlatListDemo extends Component {
constructor(props) {
super(props);

this.state = {
  loading: false,
  data: [],
  page: 1,
  seed: 1,
  error: null,
  refreshing: false,
};

}

componentDidMount() {
this.makeRemoteRequest();
}

makeRemoteRequest = () => {
const { page, seed } = this.state;
const url = https://randomuser.me/api/?seed=${seed}&page=${page}&results=20;
this.setState({ loading: true });
fetch(url)
.then(res => res.json())
.then(res => {
this.setState({
data: page === 1 ? res.results : [...this.state.data, ...res.results],
error: res.error || null,
loading: false,
refreshing: false
});
})
.catch(error => {
this.setState({ error, loading: false });
});
};

render() {
return (

<FlatList
data={this.state.data}
renderItem={({ item }) => (
<ListItem
roundAvatar
title={${item.name.first} ${item.name.last}}
subtitle={item.email}
avatar={{ uri: item.picture.thumbnail }}
/>
)}
/>

);

}
}

const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
}
});

export default FlatListDemo;

//export default App;

please help...............................................................

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComponent: FlatListRan CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions