usehooks icon indicating copy to clipboard operation
usehooks copied to clipboard

Adds tuple type in order to be able to access storedValue and setValue correctly

Open adamhalesworth opened this issue 4 years ago • 0 comments

In the useLocalStorage hook Typescript example, an explicit type is required for the function in order to be able to use the tuple correctly: [T, (value: T | ((val: T) => T)) => void].

Without this, the type for both storedValue and setValue is string | ((value: string | ((val: string) => string)) => void) which prevents using them properly.

If it looks a little ugly inline I can change it for a declared type. :+1:

adamhalesworth avatar Nov 10 '20 22:11 adamhalesworth