I need to store and update form input changes, so I added a form state:
const [form, setForm] = useState({
user: '',
email: '',
password: '',
});
I then created a function for handling form changes:
const handleFormChange = (event: { target: HTMLInputElement | HTMLTextAreaElement }) => {
const updatedForm: updatedForm = { ...form };
updatedForm[event.target.name] = event.target.value;
setForm(updatedForm);
};
I also added an interface for the updatedForm type:
interface updatedForm {
[key: string]: string;
}
But now there is an error:
Argument of type 'updatedForm' is not assignable to parameter of type 'SetStateAction<{ user: string; email: string; password: string; }>'.
Type 'updatedForm' is missing the following properties from type '{ user: string; email: string; password: string; }': user, email, password
What's wrong, and is there a solution?