Conversation
|
|
||
|
|
||
| handleSearchSubmit(){ | ||
| this.setState({ |
There was a problem hiding this comment.
It would be better to pre-calculate the searchList. That way you can set it in state and use it the fetch after without needing the use the callback in setState. Keeps code simpler
| } | ||
|
|
||
| generateComputerCard(){ | ||
| let randomPokemonNumber = Math.floor(Math.random() * (800 - 1 + 1)) + 1; |
| <div className="card"> | ||
| {this.props.playerCard.name}<br></br> | ||
| <img className="sprite" src={this.props.playerCard.sprites.front_shiny} /><br></br> | ||
| Speed: {this.props.playerCard.stats[0].base_stat}<button stat={this.props.playerCard.stats[0].base_stat} name="speed" onClick={ event => this.props.handleClick(this.props.playerCard.stats[0].base_stat, this.props.computerCard.stats[0].base_stat) }>Select</button><br></br> |
There was a problem hiding this comment.
I wonder if this might better generated using a loop rather than code duplication. The only difference between the rows is the label and index. You could create an array of labels, map over them and generate each button using the label from array and its index
| {this.props.team[${this.state.currentCardIndex}].name} | ||
| {pokemon.stats[${this.state.currentCardIndex}].stat.name}{pokemon.stats[${this.state.currentCardIndex}].base_stat}<button onClick={event => this.handleClick(pokemon)}>Select</button> | ||
| </div> | ||
| ) |
There was a problem hiding this comment.
indentation could be better here
| <tbody> | ||
| <tr> | ||
| <th>{this.props.pokemon.name}</th> | ||
| <th>{this.props.pokemon.stats[0].stat.name}</th> |
There was a problem hiding this comment.
Some loops could reduce code duplication here
| constructor(){ | ||
| super(); | ||
|
|
||
| this.state = { |
| <tbody> | ||
| <tr> | ||
| <th>{pokemon.name}</th> | ||
| <th>{pokemon.stats[0].stat.name}</th> |
There was a problem hiding this comment.
using a loop here to generate each line would reduce code duplication
|
Good work. Some code duplication could be removed using loops |
No description provided.