mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 13:09:40 +08:00
772ab49baf
* docs: fix hydration error when resizing * docs: useLayoutState
18 lines
421 B
TypeScript
18 lines
421 B
TypeScript
import { startTransition, useState } from 'react';
|
|
|
|
const useLayoutState = <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;
|