I am getting values from the form. I am using tsx for my project. But I am much unhappy to use a long element type like this:
handleChange = (e:React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLSelectElement>, id: string ) =>{
e.preventDefault();
const {value} = e.target;
this.setState((prev) => ({fields: {...this.state.fields, [id]:value}}));
console.log(id, this.state.fields);
}
where the e ( event ) has:
e:React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLSelectElement>
such a long type declaration. is there any way to shorten this? or any other type help to take care of all form elements?
Thanks in advance.