You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
421 B
18 lines
421 B
2 years ago
|
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;
|