score:23

Accepted answer

i didn't test this, but from the react bootstrap source code for formcontrol it seems like using defaultvalue prop should work:

<formcontrol type="select"
  ref="templateselect"
  defaultvalue={this.state.templateid}
  onchange={this.handletemplatechange}>
   {options}
</formcontrol>

if multi select defaultvalue must be array:

this.state = {
  templateid:['some value']
}
<formcontrol 
  multiple
  type="select"
  ref="templateselect"
  defaultvalue={this.state.templateid}
  onchange={this.handletemplatechange}>
   {options}
</formcontrol>

score:1

this way you can set the default value.

                <option  >is any default</option>
                {

                    dataoption.map(item => {

                        return <option key={item.value} vlaue={item.value} selected={defaultselect ? defaultselect == item.value ? true : false : false}  >{item.text}</option>
                    })
                }

            </formcontrol>

you may receive an error in the console:

warning: use the defaultvalue or value props on instead of setting selected on .

but setting defaultvalue or value does not solve your problem

score:1

(hi googlers!)

if you are attempting to load an array of options into the form-control (by a network-call, promise or other async function) make sure you dont render the select-field until the options-array has been fully loaded. or else the defaultvalue wont work.

(true for react-bootstrap 1.0.0-beta.8. your mileage may wary.)

score:5

with "react-bootstrap": "1.0.0-beta.14", the value prop is used:

<form.control as="select" value={user}>
    { users.map(opt => (<option>{ opt }</option>)) }
</form.control>

Related Query

More Query from same tag