'How can I fix this select dropdown in React?
I'm revisiting a React app that I created years ago because the dropdowns are no longer working. Code snippet below.
render() {
return (
<div className="players-container">
<h1 className="players-header">Choose a Player</h1>
<select className="player-options" name="player" onChange={this.props.onPickPlayer}>
{this.props.players.map(player => {
return <option className="player-selection" key={player.id} value={player.name} onClick={this.props.onPickPlayer}>{player.name}</option>
})}
</select>
</div>
)
}
}
Previously, when clicking on the dropdown a list of NBA players would be pulled from a database and returned as options. I haven't made any changes so I'm not sure what went wrong. Does anyone see any issues here with the syntax or know of a possible solution?
I tried adding an onClick function to the dropdown that would return a ul but that did not work. Also tried importing react-select but I'm not sure how to properly implement it without breaking the rest of my code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
