MadCcc
2 years ago
committed by
GitHub
3 changed files with 25 additions and 9 deletions
@ -0,0 +1,17 @@ |
|||
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; |
Loading…
Reference in new issue