Sol_is_here
Sol_is_here

Reputation: 110

email field in JSX causing error on touch

There is this bug that doesn't affect the functionality but its just there and it does bother me.

So, I have this signup form in my react.js app. Here is a basic version of it:

import { useState } from "react"
import {signupApi} from '../utils/api'


const SignUpPage = () => {
    const [credentials, setCredentials] = useState({ username: '', password: '', email:'', });
    const [error, setError] = useState(null);

    const handleSubmit = async (e) => {
        e.preventDefault();
        try {
            signupApi(credentials);
        } catch (error) {
            setError(error.message);
        }
    };

    const handleChange = (e) => {
        console.log("heyhey")
        setCredentials({
            ...credentials,
            [e.target.name]: e.target.value,
        });
    };

    return(
        <div>
            <h1>Signup</h1>
            {error && <p>{error}</p>}
            <form onSubmit={handleSubmit}>
                <div>
                    <label htmlFor="username">Username:</label>
                    <input autoComplete="off" type="text" id="username" name="username" value={credentials.username} onChange={handleChange} required />
                </div>
                <div>
                    <label htmlFor="password">Password:</label>
                    <input autoComplete="off"  type="password" id="password" name="password" value={credentials.password} onChange={handleChange}  required />
                </div>
                <div>
                    <label htmlFor="email">Email:</label>
                    <input autoComplete="off" type="email" id="email" placeholder="[email protected]" name="email" value={credentials.email} onChange={handleChange} required/>
                </div>
                <button type="submit">Signup</button>
            </form>
        </div>
    )
}

export default SignUpPage

When I click on "email" field, it creates the following error: enter image description here

And this is what I see when I open chunk.infield.js enter image description here

I already use a placeholder, I don't want any default value for email variable, it should be empty.

It looks to me like there is a validation going on at the background somewhere, but the way it works is not optimal, doesn't help really.

What could be causing this, and how can I solve it?

Upvotes: 0

Views: 66

Answers (1)

embuc
embuc

Reputation: 688

There is nothing wrong with your code. This is caused by LastPass chrome plugin. Disable it (just for test) and the error will be gone.

Upvotes: 0

Related Questions