[go: up one dir, main page]

0% found this document useful (0 votes)
40 views1 page

Week 11 Code

Uploaded by

eshaasif005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views1 page

Week 11 Code

Uploaded by

eshaasif005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import React from 'react';

import {useState, useEffect} from 'react';


import { View, Text, FlatList } from 'react-native';
import {ActivityIndicator, StyleSheet} from 'react-native';

const App = () => {


const [isLoading, setLoading] = useState(true);
const [data, setData] = useState([]);
const fetchData=async ()=>
{
const response = await fetch ('https://reactnative.dev/movies.json');

const res=await response.json()


console.log(res.movies)
setData(res.movies)
setLoading(false);

}
useEffect(() => {
fetchData();
}, [])
return (
<View style={styles.container}>
{isLoading ? <ActivityIndicator />:

<FlatList
data={data}
renderItem={({item})=>(
<Text>{item.title}, {item.releaseYear}</Text>
)}
></FlatList>}
</View>
);
};

export default App;

const styles = StyleSheet.create({


container: {
display:'flex',
marginTop:'20%',
flex: 1,
backgroundColor: 'grey',

},

});

You might also like