Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

434
Views
ReactJS: Argument of type unknown is not assignable to parameter of type SetStateAction<string> from filereader

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Already solve the issue by updating this line of code:

setBaseImage(String(base64));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!