I have a select inside a ReactJs component, which contains some options, and I would like the selected option to be added to another select that is in another component. Example:
const conponent1 = () => {
return <>
<select>
<option value="">Select a option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<component2 />
</>
}
const component2 = () => {
return <>
<select>
<option value="">Select a option</option>\
//It does not contain any options because one has not yet been chosen in the previous select.
</select>
</>
}
The user selects option 2, so this option must be added to the select of the second component.
const conponent1 = () => {
return <>
<select>
<option value="">Select a option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option> // Chosen option.
<option value="3">Option 3</option>
</select>
<component2 />
</>
}
const component2 = () => {
return <>
<select>
<option value="">Select a option</option>\
<option value="2">Option 2</option> // It was added because it was the chosen option.
</select>
</>
}