Skip to content

Commit b25df79

Browse files
useLocalStorage Type detection bug (#409)
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.
1 parent 314b1b3 commit b25df79

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/basic/useful-hooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function App() {
3737
}
3838

3939
// Hook
40-
function useLocalStorage<T>(key: string, initialValue: T) {
40+
function useLocalStorage<T>(key: string, initialValue: T) : [T, (value: T | ((val: T) => T)) => void] {
4141
// State to store our value
4242
// Pass initial state function to useState so logic is only executed once
4343
const [storedValue, setStoredValue] = useState<T>(() => {

0 commit comments

Comments
 (0)