I want to why my code is not working and causing me this error Argument of type 'unknown' is not assignable to parameter of type 'SetStateAction<string>'. Type 'unknown' is not assignable to type '(prevState: string) => string'.ts(2345).
This error is from this code setBaseImage(base64); of this function:
const uploadImage = async (e: any) => { const file = e.target.files[0]; const base64 = await convertBase64(file); setBaseImage(base64); }; Current code:
const [baseImage, setBaseImage] = useState(""); const convertBase64 = (file: any) => { return new Promise((resolve, reject) => { const fileReader = new FileReader(); fileReader.readAsDataURL(file); fileReader.onload = () => { resolve(fileReader.result); }; fileReader.onerror = (error) => { reject(error); }; }); }; I just follow this tutorial source of the code