Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LoginForm extends Component {
- constructor(props) {
- super(props)
- this.state = {
- details: {
- email: '',
- password: '',
- },
- hasError: false,
- errorText: 'Errors: n',
- }
- }
- render() {
- let { hasError, errorText } = this.state
- const { LogUserIn } = this.props
- const onTapLogin = e => {
- // broken?
- if (hasError) {
- this.setState({
- hasError: false,
- errorText: 'Errors: n',
- })
- }
- if (!check.emailValid(e.email)){
- this.setState({
- hasError: true,
- errorText: errorText += "n - Email address is invalid. "
- })
- }
- if (!check.passwordValid(e.password)){
- this.setState({
- hasError: true,
- errorText: errorText += "n- Password is invalid. "
- })
- }
- if (!hasError){
- LogUserIn(e)
- }
- }
- return (
- <div {...cssLoginFormContainer}>
- <div {...cssLoginFormHeader}>SIGN IN</div>
- <div {...(hasError ? cssErrorText : cssErrorText_hide)}>
- {errorText}
- </div>
- ...
- // the form.
Add Comment
Please, Sign In to add comment