Last active
January 30, 2020 05:24
-
-
Save luillyfe/eaa5b82a753ee462855e640bd0e5239f to your computer and use it in GitHub Desktop.
Async rendering: React
This file contains 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
<GridList cellHeight={160} className={classes.gridList} cols={3}> | |
{pokemons ? ( | |
pokemons.map(async ({ pokemon }) => { | |
const url = await getPokemon(pokemon.url); | |
return ( | |
<GridListTile key={pokemon.name} cols={1}> | |
<img src={url} alt={pokemon.name} /> | |
</GridListTile> | |
); | |
}) | |
) : ( | |
<div /> | |
)} | |
</GridList> |
This file contains 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
pokemons.map(async ({ pokemon }) => { | |
const url = await getPokemon(pokemon.url); | |
return ( | |
<Suspense fallback={<h1>Loading pokemons...</h1>}> | |
<GridListTile key={pokemon.name} cols={1}> | |
<img src={url} alt={pokemon.name} /> | |
</GridListTile> | |
</Suspense> | |
); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment