c0micrage
c0micrage

Reputation: 1180

ReactJS Reactstrap input dropdown not showing selected value

I am using reactstrap with React JS and trying to figure out how to bind the input dropdown list. When the data is coming in, the optionID can be from any from 1 to 5. I would expect that when I bring up the UI, the dropdown is always showing Select option and never the other. I thought if I set the selected={this.state.optionID === Input.value} it would make it work.

Any help is appreciated. Thanks.

<Input type="select" name="select" id="statusDropDown" 
value={this.state.optionID} selected={this.state.optionID === Input.value}  
onChange={this.handleOptionChange}>
                                    <option value={0}>Select</option>
                                    <option value={1}>Option 1</option>
                                    <option value={2}>Option 2</option>
                                    <option value={3}>Option 3</option>
                                    <option value={4}>Option 4</option>
                                    <option value={5}>Option 5</option>
                                </Input>

Upvotes: 0

Views: 1115

Answers (1)

Jeevan
Jeevan

Reputation: 538

Please find the working sample here. My suggestion is to use a functional component.

Upvotes: 1

Related Questions