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

432
Views
ReactJS: el argumento de tipo desconocido no se puede asignar al parámetro de tipo SetStateAction<string> del lector de archivos

Quiero saber por qué mi código no funciona y me causa este 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) .

Este error proviene de este código setBaseImage(base64); de esta función:

 const uploadImage = async (e: any) => { const file = e.target.files[0]; const base64 = await convertBase64(file); setBaseImage(base64); };

Código actual:

 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); }; }); };

Solo sigo este tutorial fuente del código.

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

0

Ya resuelva el problema actualizando esta línea de código:

 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!