mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
18 lines
438 B
TypeScript
18 lines
438 B
TypeScript
import { startTransition, useState } from 'react';
|
|
|
|
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;
|