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

61
Visualizações
how to destructure react hook so that unused variable no needed to decalare
const [loggedInUser, setLoggedInUser] = useContext(userContext);

in this line I just need to use only setLoggedInUser. I do not need to use loggedInUser here. Now how could I get the setLoggedInUser without declaring loggedInUser. Because there are some worning "

Line 15:12: 'loggedInUser' is assigned a value but never used no-unused-vars

How can I get rid of this warning?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You don't need to declare it at all

const [,setLoggedInUser] = useContext(userContext)

Alternatively, this is easy as well:

const setLoggedInUser = useContext(userContext)[1]

Personal preference.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can do this :

const = { setLoggedInUser } = useContext(userContext)
about 4 years ago · Juan Pablo Isaza Relatório

0

I think there is no need for destructuring:

const setLoggedInUser = useContext(userContext)[1];
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