Skip to content

Commit 9701831

Browse files
davidwedovidweisz
authored andcommitted
fix: Update initialState type to allow for lazy initialization
1 parent 325f5bd commit 9701831

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)