Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting an error in my code of handleSubmit function because ,here I am using this syntax 'export const Register = ()',so what needs to be fixed in my code so that I;m able to use the handleSubmit function I'll paste the code down below it keeps saying its not defined ive tried adding function handleSubmit() and const handleSubmit = () but its still not working any help on how to resolve this error please


export const Register = () => {

handleSubmit = e => {
    e.preventDefault();
    console.log('works!');
};

return (

    <form onSubmit={this.handleSubmit}>
        <h3>Sign Up</h3>

        <div className="form-group">
            <label> First Name</label>
            <input type="text" className="form-control" placeholder="First Name" />
        </div>

        <div className="form-group">
            <label> Last Name</label>
            <input type="text" className="form-control" placeholder="Last Name" />
        </div>

        <div className="form-group">
            <label> Email</label>
            <input type="email" className="form-control" placeholder="Email" />
        </div>

        <div className="form-group">
            <label> Password</label>
            <input type="password" className="form-control" placeholder="Password" />
        </div>`

        <div className="form-group">
            <label> Confirm Password</label>
            <input type="password" className="form-control" placeholder="Confirm Password" />
        </div>`

        <button className="btn btn-primary btn-block">Sign Up</button>

    </form>
);
}

export default Register;


What I have tried:

Quote:
I am getting an error in my code of handleSubmit function because ,here I am using this syntax 'export const Register = ()',so what needs to be fixed in my code so that I;m able to use the handleSubmit function I'll paste the code down below it keeps saying its not defined ive tried adding function handleSubmit() and const handleSubmit = () but its still not working any help on how to resolve this error please

Posted
Comments
Andre Oosthuizen 26-Feb-22 2:21am    
Not working is not helping us, post the error message so we can see what is undefined.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900