Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6211

How can i handle the file choose event?

$
0
0

I get a compile error when I try to handle the file choose event for the input

const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>) => {  const newValue = e.currentTarget.files;  onChange(newValue.length ? newValue : undefined, e);};return (<div className={clNames}><input      name={name}      type="file"      accept={extension}      multiple={multiple}      onChange={onChangeHandler}    /></div>);

I get the following error:

TS2531: Object is possibly 'null'.TS2345: Argument of type 'FileList | null | undefined' is not assignable to parameter of type 'string | undefined'.

I am very new to React, could you please help me?


Viewing all articles
Browse latest Browse all 6211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>