Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

435
Vistas
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 Respuestas
Responde la pregunta

0

Already solve the issue by updating this line of code:

setBaseImage(String(base64));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda