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?
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.
You can do this :
const = { setLoggedInUser } = useContext(userContext)
I think there is no need for destructuring:
const setLoggedInUser = useContext(userContext)[1];