Skip to content

Instantly share code, notes, and snippets.

@erichulburd
Created October 13, 2016 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erichulburd/0ee8c0e8063915fda2911b17c4205d9b to your computer and use it in GitHub Desktop.
Save erichulburd/0ee8c0e8063915fda2911b17c4205d9b to your computer and use it in GitHub Desktop.
Autofill Safe
<!-- current component -->
<input type="email"
name="email"
class="form-control"
placeholder="Email Address"
value="{this.login.email}"
onChange="{this.loginFieldChanged.bind(this)}"
required/>
<!-- refactored component -->
<AutofillSafe type="email"
name="email"
class="form-control"
placeholder="Email Address"
value="{this.login.email}"
onChange="{this.loginFieldChanged.bind(this)}"
required="{true}"/>
<!-- Shared Component -->
class AutofillSafeInput extends BhApplicationComponent {
static get propTypes(){
return {
onChange: React.PropTypes.func.isRequired
}
}
render(){
return (<input
ref={(input)=>{ if (input.value) this.props.onChange({target: input}) }}
{...this.props}/>);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment