From 71df5ab25efb079322c7314b90aed6139795191e Mon Sep 17 00:00:00 2001 From: mmdHasan-yazdanPanah <63463742+mmdHasan-yazdanPanah@users.noreply.github.com> Date: Sat, 24 Apr 2021 09:42:07 +0430 Subject: [PATCH] useLocalStorage Type detection bug in my vs code it detects that the type of soredValue is (T | (value: T | ((val: T) => T)) => void) but it must be just (T) so it throws error with this change it solved. --- docs/basic/useful-hooks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/basic/useful-hooks.md b/docs/basic/useful-hooks.md index dea956a0..8821ffc3 100644 --- a/docs/basic/useful-hooks.md +++ b/docs/basic/useful-hooks.md @@ -37,7 +37,7 @@ function App() { } // Hook -function useLocalStorage(key: string, initialValue: T) { +function useLocalStorage(key: string, initialValue: T) : [T, (value: T | ((val: T) => T)) => void] { // State to store our value // Pass initial state function to useState so logic is only executed once const [storedValue, setStoredValue] = useState(() => {