I have a React app (with React Segment UI), which so far is working fine. I have a login form where, as any login form, I allow it to be auto-filled by either a password manager or the browser. What I would like to do is grab the values in the pre-filled forms, mainly to check if they have already been filled.
How can I do that?
This is currently what my component looks like:
export default class SignIn extends React.PureComponent {
handleSubmit (evt) {
// handle submit
}
isSignInDisabled () {
// Would like to check here is the email and password
// have been prefilled since with this method it won't work
// in this case.
return (
!this.props.email.length ||
!this.props.password.length
)
}
render () {
const { email, password } = this.props
return (
<Form onSubmit={evt => {
this.handleSubmit(evt)
}}>
<Form.Field>
<Form.Input
type='email'
label='Email'
value={email}
onChange={evt => setEmail(evt.target.value)}
/>
</Form.Field>
<Form.Field>
<Form.Input
type='password'
label='Password'
value={password}
onChange={evt => setPassword(evt.target.value)}
/>
</Form.Field>,
<Form.Field>
<Button type='submit' disabled={this.isSignInDisabled()}>Sign In</Button>
</Form.Field>
</Form>
)
}
}