reactjs - Redux Form - Return current input value as string onChange -
i'm trying show 'tick' next input when contains @ least 1 character show required field being valid. issue have when console.log(textentered)
each time field changes receive object containing typed letters instead of complete string. if typed in 'hello' example log looks (ignore undefined):
here redux field component:
handleinput = (textentered) => { console.log(textentered); this.setstate({ textentered }, () => { if (this.state.textentered.length) { this.setstate({ completed: true }); } else { this.setstate({ completed: false }); } }); } render() { return ( <field name={this.props.placeholdertext} component={textinput} onchange={this.handleinput} /> ); } const textinput = (field) => { return ( <div classname="drill-creation-input"> <input {...field.input} type="input" onchange={e => field.input.onchange(e.target.value)} /> <label htmlfor={field.input.name}> <span>{field.input.name}</span> </label> </div> ); };
onchange handler has following signature (see docs)
onchange : (event, newvalue, previousvalue)
so read complete value, define handleinput
like:
handleinput = (evnt, textentered) => { console.log(textentered); ... }
Comments
Post a Comment