Created
October 19, 2018 11:13
-
-
Save darksh3ll/4aeb6045732205dc3f7bda491f55548b to your computer and use it in GitHub Desktop.
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, { Component } from 'react' | |
| const arr = [12,23,56] | |
| class DisplayPokemon extends Component { | |
| state = { | |
| data:[] | |
| } | |
| //!Lance la function au demarrage | |
| componentDidMount() { | |
| this.fetchData() | |
| } | |
| //Récupere data | |
| fetchData = async () => { | |
| const data = await fetch("https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json") | |
| const json = await data.json(); | |
| this.setState({data:json.pokemon}) | |
| } | |
| render () { | |
| return ( | |
| <div> | |
| { | |
| this.state.data.map((x) => { | |
| return ( | |
| <div> | |
| <ul> | |
| <img src={x.img} alt="#" srcset=""/> | |
| <li>{x.name}</li> | |
| </ul> | |
| <button>Click</button> | |
| </div> | |
| ) | |
| }) | |
| } | |
| </div> | |
| ) | |
| } | |
| } | |
| export default DisplayPokemon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment