mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
17 lines
350 B
TypeScript
17 lines
350 B
TypeScript
import { startTransition, useCallback, useState } from 'react'
|
|
|
|
export const useTransitionState = ((val) => {
|
|
const [a, b] = useState(val)
|
|
// @ts-ignore
|
|
const wrapped = useCallback(
|
|
(...args) => {
|
|
startTransition(() => {
|
|
// @ts-ignore
|
|
b(...args)
|
|
})
|
|
},
|
|
[b]
|
|
)
|
|
return [a, wrapped]
|
|
}) as typeof useState
|