Created
October 13, 2016 21:51
-
-
Save erichulburd/0ee8c0e8063915fda2911b17c4205d9b to your computer and use it in GitHub Desktop.
Autofill Safe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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