transformation de listItem en component indépendant, et utilisation d'une child props

pull/6/head
Pierre Ferreira 2 years ago
parent 67aea8e360
commit 55d22852b8

@ -0,0 +1,17 @@
import { View } from 'react-native';
import { Image } from 'react-native';
type ItemProps = {
url : string //Image URL
}
export function ListItemComponent(props : ItemProps){
return (
<View>
<Image
source={{uri: props.url}}
style={{flex:1, minHeight:250, minWidth:180}}/>
</View>
)
}

@ -56,8 +56,9 @@ export const getAllCards = () => {
headers: {
'content-length': '9508',
'content-type': 'application/json; charset=utf-8',
'etag': 'W/"74bb-d4gMlMNks7UGES3Jmn6wzUTXaLI"'
'etag': 'W/"74bb-d4gMlMNks7UGES3Jmn6wzUTXaLI"',
}
//'pageSize':'100'
};
//! Actualisation de l'API (16/03) :
const CardsPromise = await fetch('https://us.api.blizzard.com/hearthstone/cards?locale=en_US&access_token=EU1AbKy9Q7sOUjQYC5AFF1O1JPuoAgCNxk', options);

@ -17,22 +17,11 @@ import { Image } from 'react-native';
import { ImageURISource } from 'react-native';
//* Icons
// import { BiSearchAlt } from 'react-icons';
//* Components
import {ListItemComponent} from '../components/ListItemComponent'
//@ts-ignore
const Item = ({url}) => (
// <View style={styles.item}>
// <Text style={styles.title}>{title}</Text>
// </View>
<View>
<Image
source={{uri:url}}
style={{flex:1, minHeight:250, minWidth:180}}/>
</View>
);
//@ts-ignore
export default function ListScreen({navigation}){
@ -89,7 +78,7 @@ export default function ListScreen({navigation}){
data={filteredList}
renderItem={({item}) =>
<TouchableHighlight onPress={() => navigation.navigate("ListFav")}>
<Item url={item.img}/>
<ListItemComponent url={item.img}/>
</TouchableHighlight>
}
keyExtractor={(item: Card) => item.id.toString()}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save