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

178
Vistas
React readOnlyError.js:2 Uncaught (in promise) TypeError: "searchData" is read-only

As you can see in the code below that while typing or searching, the user also searches the data in the database for what the user is typing.

  const searchData = useState();
  const fetchSearchPerson = async (name) => {
    const { data } = await client.query({
      query: SEARCH_PERSON,
      variables: {
        name: name
      },
    })
     searchData = new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve (data); 
      }, 1000);
    });
    return data;
  };

.....

  fetchSearchPerson(params.suggestTerm)
  return searchData.map((data) => {
    console.log("datas: ", data)
  });
 .....

Error I have encountered so far:

enter image description here

UPDATE

const [searchData, setSearchData] = useState();
  
  const fetchSearchPerson = async (name) => {
   
    const { data } = await client.query({
      
      query: SEARCH_PEOPLE,
      variables: {
        name: name,
      },
    })
    const searchDataPromise = new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve (data); 
      }, 1000);
    });
    setSearchData(searchDataPromise); // add this
    return data;
  };

 fetchSearchPerson(params.suggestTerm)
 return searchData.map((data) => {
    console.log("datas: ", data)
  })

I dont received the error but the result from the search data

about 4 years ago · Juan Pablo Isaza
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