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

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

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 Denunciar

0

You can do this :

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

0

I think there is no need for destructuring:

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