Reputation: 1462
I have implemented a hook that returns an array with two elements like below.
export function useSearchParams() {
..
../
return [searchParams, setSearchParams];
}
I only need to access this setSearchParams
element in my component.
const [{},setSearchParams] = useSearchParams();
This throws an es-lint warning when I add {}
for the first parameter. What is the best practice on this? If I only want to access the second parameter?
Upvotes: 1
Views: 104
Reputation: 20431
You can do something like this:
const [,setSearchParams] = useSearchParams();
Example:
let arr = [1,3];
let [,ans] = arr;
console.log(ans);
Upvotes: 2