0

I have a project with more components and I have a table with that appears by clicking on a button, I make some selections and make the table to disappear and reappear but I doesn't keep the selected values.

Can I make the "form.control" to keep my selected item ?

Here is the code from the table.

<Table>
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Provide or not</th>
                        <th>Link where to find it</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>HASI</td>
                        <td>
                            <Form.Control as="select">
                                <option>Provided_by_prj</option>
                                <option>Use_internal</option>
                            </Form.Control>
                        </td>
                        <td><FormControl aria-label="Small" aria-describedby="inputGroup-sizing-sm" /></td>
                    </tr>

B001ᛦ
  • 2,036
  • 6
  • 23
  • 31
Cristian GATU
  • 49
  • 1
  • 4

1 Answers1

0

You can force set your values, reactjs should be doing this for you... Maybe there's a problem elsewhere too.

<option value={option.value} selected={optionsState == option.value}>{option.label}</option>

or something in the like of

<Form.Control as="select" value={optionsState}>
  <option value=1>Provided_by_prj</option>
  <option value=2>Use_internal</option>
</Form.Control>

See React JSX: selecting "selected" on selected <select> option

Joe DF
  • 5,438
  • 6
  • 41
  • 63