I have the following class that lists a series of volcanoes with code and name:
import React, { useState } from 'react';
import {useFetchVolcans} from '../assets/hooks/useFetchVolcans';
import Accordion from 'react-bootstrap/Accordion';
function Bar() {
//realizo una petición para pedir la lista de los volcanes y su codigos
const {data} = useFetchVolcans()
const [volcanInicio,setVolcanInicio] = useState()
//Aquí se modifica el código guardado si se elige uno u otro volcán de la lista
const handleVolcanInicio = (e)=>{
setVolcanInicio(e.target.value)
}
return(
<div className="barLeft">
//Aquí listo la información en un botón desplegable
<Accordion>
<Accordion.Item eventKey="0">
<Accordion.Header>Volcanes</Accordion.Header>
<Accordion.Body>
<select value={volcanInicio} onChange={handleVolcanInicio} class="form-select">
<option value="0">Elige un volcan</option>
{data.map((item) => (
<option value={item.code}>{item.name}</option>
))}
</select>
</Accordion.Body>
</Accordion.Item>
</Accordion>
</div>
);
}
export default Bar;
What I need is to send the information of the code saved in setVolcanInicio to another class and that this is done every time a volcano is chosen from the list.