Skip to content

Commit

Permalink
fix: Update initialState type to allow for lazy initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwe authored and dovidweisz committed May 24, 2023
1 parent 325f5bd commit 9701831
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/useSetState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useState } from 'react';

const useSetState = <T extends object>(
initialState: T = {} as T
initialState: T | (() => T) = {} as T
): [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void] => {
const [state, set] = useState<T>(initialState);
const setState = useCallback((patch) => {
Expand Down

0 comments on commit 9701831

Please sign in to comment.