Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

268
Visualizações
I have the error object are not valid as tract child (found object...) When i call a async function

I try to call Octokit api (github) to check if i follow the people who follows me.

There is my code:

followers.map((followers) =>{
                    return(
                      
                     <Text>
                   {followers.login}
                   <Text>
                    isFollowing?
                   </Text>
                   {checkisFollowing(followers.login)}
                   
...

and there is my function check is gollowing(fanfan)

  const checkisFollowing = async(fanfan) => {
    console.log(fanfan, "is following?")


    return("1")

  }
and it gives me the error 

Objects are not valid as a React child (object with keys {_U, _V, _W, _X})



I already checked on internet but i don't find the solution.


Thanks for your answers!
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If the function is async and you are requesting something from API, you should have a state. When checkisFollowing you should update the state, and on return you display the state value:

const [checkFollowingState, setCheckFollowingState] = useState("");

const checkisFollowing = async(fanfan) => {
    console.log(fanfan, "is following?")
    // so async work

    setCheckFollowingState("1")
  }

return (
 <Text>
   {checkFollowingState}
 </Text>

If you have multiple requests, you can do:

Promise.all([someAsyncRequest]).then(checkisFollowingArray => setCheckFollowingState(checkisFollowingArray))
...
return (
 <Text>
   {checkFollowingState[0]}
 </Text>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda