I'm using React-Select and have two dropdowns on my page. When the first dropdown is selected it changes the value of the 2nd dropdown successfully but I'm trying to get the onChange on the 2nd dropdown to change when that happens also. Is there a way to do that? I made a codesandbox of a simple example of what I'm trying to accomplish
import React, {useState} from "react";
import Select from 'react-select';
import "./styles.css";
export default function App() {
const [genre, setGenre] = useState()
const artistslist = [
{value: 'ACDC', label: 'AC/DC'},
{value: 'LZ', label: 'Led Zeppelin'},
{value: 'Garth', label: 'Garth Brooks'},
{value: 'Alan', label: 'Alan Jackson'}
]
const genrelist = [
{value: 'rock', label: 'Rock'},
{value: 'country', label: 'Country'}
]
const handleArtistChange = (event) => {
console.log(event)
if (event.value === 'LZ' || event.value === "ACDC") {
setGenre({value: 'rock', label: 'Rock'})
} else {
setGenre({value: 'country', label: 'Country'})
}
console.log(genre)
}
const handleGenreChange = (event) => {
console.log("Genre Changed")
}
return (
<div className="App">
<Select options={artistslist} onChange={handleArtistChange} />
<Select options={genrelist} value={genre} onChange={handleGenreChange} />
</div>
);
}
Selectto be changed when the secondSelectchanges?