Skip to content

Commit 6cc6ca3

Browse files
author
davidwe
committed
fix: Update initialState type to allow for lazy initialization
1 parent 325f5bd commit 6cc6ca3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/useSetState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCallback, useState } from 'react';
22

33
const useSetState = <T extends object>(
4-
initialState: T = {} as T
4+
initialState: T | (() => T) = {} as T
55
): [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void] => {
66
const [state, set] = useState<T>(initialState);
77
const setState = useCallback((patch) => {

0 commit comments

Comments
 (0)