'React Auto Complete Element along with options to add value to the list if not present

i have to create an autocomplete react component. Initially there must be 5 autocomplete fields. I set a state as an array of 5 input elements like

this.state {activities : ['','','','','']}

i apply a map function over these to display 5 autocomplete boxes.

I have a list of values to be listed as options of autocomplete.

Row>
                    {this.state.activities.map((newrow,index)=>{
                            return (
                                <Col md={12}>   
                                    <Row className="form-row">
                                        <Col md={11} sm={10} xs={9}>
                                            <div className="form-input">
                                               <AutoComplete
                                                    className="autosearch"
                                                    dataSource={options}
                                                    onSelect={this.onSelect.bind(this, index)}
                                                    filterOption={(inputValue, option) =>  option.props.children.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1} />

                                            </div>
                                        </Col>
                                        <Col md={1} sm={2} xs={3}>
                                            <Button className="delete-row" onClick={this.deleterow.bind(this,index)}><i className="fa fa-trash"></i></Button>
                                        </Col>
                                    </Row>
                                </Col>)
                            })
                        }  

                </Row>

now i have to create an autocomplete which also has the option to allow me add an option if it is not present in the list .

please help me out. i am new to react and thanks in advance.

This is the website i referred for the autocomplete boxenter link description here

and i referred the basic example code of it



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source