Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

59
Views
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 answers
Answer question

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 Report

0

You can do this :

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

0

I think there is no need for destructuring:

const setLoggedInUser = useContext(userContext)[1];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!