I have the following code below that is loaded on a user profile page. Each user has a Planting System. When loading the code below, the application should select the user's respective Plant System. However, this is not happening because I am not able to use the selected option related to the user who loaded the page.
<Input
type="select"
name="planting_system_id"
id="planting_system_id"
value={planting_system_id}
autoComplete="planting_system_id"
className="form-control"
placeholder={apiData ? "Planting System" : "Loading..."}
disabled={apiData ? false : true}
onChange={(ev) => this.onChangeInput("planting_system_id", ev)}
>
<option value="">Select...</option>
{plantingSystemsList.map(ps => (
<option value={ps.id} key={ps.id}>
{ps.description}
</option>
))}
</Input>
And when trying to use the select in option list, there is an error on the part of React that I should use defaultValue or value instead of selected. However, I am not sure how to do this.