i have a code that is changing image
const [cars] = useState([
{
title2: "Sahara Brown",
image: "images/brown.jpg",
},
{
title2: "Carbon Black",
image: "images/black.jpg",
},
{
title2: "SPL Green",
image: "images/gren.jpg",
},
{
title2: "Ghost White",
image: "images/white.jpg",
},
]);
const [carImage, setCarImage] = useState(cars[0].image);
<div class="image-wrap">
<img
id="cars"
src={carImage} setCarColor={setCarColor} setCarImage={setCarImage} />
</div>
<select
onChange={() => {setCarImage(car.image); setCarColor(car.title2);}}
value={carImage}
id="variation-select"
>
{cars.map((car) => (
<option data-color={car.title2} value={car.image}>{car.title2}</option>
))}
</select>
when i change the option the image changes im okay with that but as you can see there is title2 on there i want to get both what imean by that is it will both change the image and set the title as that title how can i do that i want to use both image and the title.
thank you.