Last active
May 17, 2020 15:06
-
-
Save eyalcohen4/c04142ce7a6e0d65552cd3d8db745037 to your computer and use it in GitHub Desktop.
React Native Lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
function Pokemons() { | |
} | |
export default Pokemons |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { | |
View, | |
Text, | |
Image, | |
FlatList | |
} from 'react-native' | |
import usePokemons from './use-pokemons' | |
function Pokemons() { | |
const pokemons = usePokemons() | |
return ( | |
<FlatList | |
data={pokemons} | |
renderItem={({ item }) => ( | |
<View> | |
<Text>{item.name}</Text> | |
<Image source={{ uri: image }} style={{ height: 50, width: 50 }} /> | |
</View> | |
)} | |
keyExtractor={(item) => item.name} | |
/> | |
) | |
} | |
export default Pokemons |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { | |
View, | |
Text, | |
Image, | |
FlatList | |
} from 'react-native' | |
import usePokemons from './use-pokemons' | |
const Pokemon: React.FC<Partial<IPokemon>> = ({ | |
name, | |
image, | |
}: Partial<IPokemon>) => { | |
return ( | |
<View style={pokemonStyles.container}> | |
<Text style={pokemonStyles.name}>{name}</Text> | |
<Image source={{ uri: image }} style={pokemonStyles.image} /> | |
</View> | |
) | |
} | |
export default function Pokemons() { | |
const pokemons = usePokemons() | |
const renderPokemon = ({ item }: { item: IPokemon }) => { | |
return <Pokemon name={item.name} image={item.image} /> | |
} | |
return ( | |
<FlatList | |
style={styles.list} | |
data={pokemons} | |
renderItem={renderPokemon} | |
keyExtractor={(item) => item.name} | |
/> | |
) | |
} | |
export default Pokemon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { | |
View, | |
Text, | |
Image, | |
FlatList | |
} from 'react-native' | |
import usePokemons from './use-pokemons' | |
function Pokemons() { | |
const pokemons = usePokemons() | |
const renderPokemon = ({ item }: { item: IPokemon }) => { | |
return ( | |
<View> | |
<Text>{item.name}</Text> | |
<Image source={{ uri: item.image }} style={{ height: 50, width: 50 }} /> | |
</View> | |
) | |
} | |
return ( | |
<FlatList | |
style={styles.list} | |
data={pokemons} | |
renderItem={renderPokemon} | |
keyExtractor={(item) => item.name} | |
/> | |
) | |
} | |
export default Pokemons |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import usePokemons from './use-pokemons' | |
function Pokemons() { | |
const pokemons = usePokemons() | |
} | |
export default Pokemons |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment