Typescript is giving me the following error
const handleSignIn: (e: React.SyntheticEvent) => Promise<void> Promise-returning function provided to attribute where a void return was expected.
for the following code <form onSubmit={handleSignIn}>
. It does the work and sends the registration email but I am still getting the error from the typescript. I tried to solve the issue with this and it does help with TS error but the code will not work.
import React, { useState } from "react";
import { signIn } from "next-auth/react";
function RegisterPage() {
const [email, setEmail] = useState("");
const handleSignIn = async (e: React.SyntheticEvent): Promise<void> => {
e.preventDefault();
try {
await signIn("email", {
email,
redirect: false,
callbackUrl: "/",
});
} catch (error) {
console.log(error);
}
};
const registerForm = () => (
<form onSubmit={handleSignIn}>
<input
type="email"
className="form-control"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Your email"
autoFocus
/>
<br />
<button type="submit" className="btn btn-raised">
Sign In
</button>
</form>
);
return (
<div className="container p-5">
<div className="row">
<div className="col-md-6 offset-md-3">
<h4>Register</h4>
{registerForm()}
</div>
</div>
</div>
);
}
export default RegisterPage;