0

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>

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.