javascript - Default Value in react-select -


i have react-select component made compatible redux-form. selectinput component this:

const myselect = props => (   <select     {...props}     value={props.input.value}     onchange={value => props.input.onchange(value)}     onblur={() => props.input.onblur(props.input.value)}     options={props.options}     placeholder={props.placeholder}   /> ); 

and render in component form

<div classname="select-box__container">                 <field                   id="side"                   name="side"                   component={selectinput}                   options={sideoptions}                   value="any"                   clearable={false}                   // placeholder="select side"                 />               </div> 

i've set initial values container state component has initial value , it's working. problem when render component initial value not show in selection box , it's empty. why happenning?

ran similar issue. input value field unset though passed. can either create input object has value prop (and other required props) or use separate prop selectedvalue in case.

 <field   id="side"   name="side"   component={selectinput}   options={sideoptions}   value="any"   clearable={false}   selectedvalue={this.props.myvalue}  />  const myselect = props => (   <select    {...props}    value={(props.input.value) ? props.input.value : props.selectedvalue}    onchange={value => props.input.onchange(value)}    onblur={() => props.input.onblur(props.input.value)}    options={props.options}    placeholder={props.placeholder}   /> ); 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -