Home > Mobile >  How to get only one set state function from use state or some other hook React JS,
How to get only one set state function from use state or some other hook React JS,

Time:10-17

I am using const [cookie, setCookie] = useCookies(["user_token"]) cookies, I only want to use setCookie and not use cookie variable. and tslint is crashing build for unused cookie. how can i get only one setCookie or pass this issue.

CodePudding user response:

What you're doing here is called "deconstructing", and it is possible to ignore first element like this:

[, setCookie] = useCookies(["user_token"])

See this answer for more explanation: Destructuring array get second value?

CodePudding user response:

...or pass this issue.

Add this line just before the line which causes the error:

  /* tslint:disable:no-unused-variable */
  • Related