Maybe you can add a command/line that ignores that line from typescript checks
could you try to set the event type
async (e: React.ChangeEvent<HTMLInputElement>)
pls how do i do that
Object is possibly 'null'
you could have
const onChangeAvatar = async (e: React.ChangeEvent<HTMLInputElement>) => {
let file;
if (e.target.files && e.target.files[0]) {
file = e.target.files[0]
}
..the rest of your code
}
let file: File | undefined
Argument of type ‘File | undefined’ is not assignable to parameter of type ‘ValidFileInput’.
Type ‘undefined’ is not assignable to type ‘ValidFileInput’.``
Maybe is not a typescript error and an error on execution time because that e.target is undefined
please what should i do… bcause i can not get the image uploaded
Maybe is a different syntax to get access to the image content.
please can you help me with an example code … i have been doing this for days now
You can search solutions on forum for same problem. I don’t know exactly how it should be the code.
i finally got it to work by using it like this (file as any)
you say that it is fixed now?
const onChangeAvatar = async (e: React.ChangeEvent<HTMLInputElement>) => {
let file;
if (e.target.files && e.target.files[0]) {
file = e.target.files[0]
}
let fileIpfs:any = await saveFile(currentUserId, (file as any), { saveIPFS: true });
console.log(fileIpfs._ipfs);
setFile(fileIpfs._ipfs);
}
that fixed it for me