Untitled
4 years ago in Plain Text
const Pokemon = (props) =>{
const pokemonName = props.pokemonName;
const [pokemon, setPokemon] = useState(0);
useEffect(() => {
axios.get("https://pokeapi.co/api/v2/pokemon/".concat(pokemonName))
.then(res => {
setPokemon(res.data);
console.log(pokemon);
})
})
if(pokemon)
{
return(
<div>
{"ID #" + pokemon.id}
<br />
<img alt ="pokemonImage" />
</div>
);
}
else
{
return(
<div>
ID #00000
</div>
)
}
}