简体   繁体   中英

What is type for file upload Event in react typescript?

I want to add type in code but I don't know about what type can I use

const handleFileChange = (e: any>) => {
setCollect({
  ...collect,
  [e.target.name]: e.target.files[0],
 });
};

I won't use any, how can I fix it

Proper typing for this event is the following:

React.ChangeEvent<HTMLInputElement>

It will let you access e.target.files .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM