message: fix: optimize useSetState ts
diff: import { useCallback, useState } from 'react';
  import { isFunction } from '../utils';
  -const useSetState = <T extends Record<string, any>>(
  - initialState: T = {} as T,
  -): [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void] => {
  - const [state, setState] = useState<T>(initialState);
  +export type SetState<S extends Record<string, any>> = <K extends keyof S>(
  + state: Pick<S, K> | null | ((prevState: Readonly<S>) => Pick<S, K> | S | null),
  +) => void;
  +
  +const useSetState = <S extends Record<string, any>>(
  + initialState: S | (() => S),
  +): [S, SetState<S>] => {
  + const [state, setState] = useState<S>(initialState);
  const setMergeState = useCallback((patch) => {
  - setState((prevState) => ({ ...prevState, ...(isFunction(patch) ? patch(prevState) : patch) }));
  + setState((prevState) => {
  + const newState = isFunction(patch) ? patch(prevState) : patch;
  + return newState ? { ...prevState, ...newState } : prevState;
  + });
  }, []);
  return [state, setMergeState];
  