ant-design/.dumi/hooks/useLayoutState.ts

18 lines
438 B
TypeScript
Raw Normal View History

import { startTransition, useState } from 'react';
2023-10-15 19:17:32 +08:00
const useLayoutState: typeof useState = <S>(
...args: Parameters<typeof useState<S>>
): ReturnType<typeof useState<S>> => {
const [state, setState] = useState<S>(...args);
const setLayoutState: typeof setState = (...setStateArgs) => {
startTransition(() => {
setState(...setStateArgs);
});
};
return [state, setLayoutState];
};
export default useLayoutState;