This commit is contained in:
john 2025-05-03 20:18:08 +02:00
parent 2586dc87c8
commit e84cf232a5
13 changed files with 605 additions and 139 deletions

13
src/hooks/useAsyncData.ts Normal file
View file

@ -0,0 +1,13 @@
import { useEffect, useState } from 'react'
export function useAsyncState<T>(loader: () => Promise<T>): T | undefined {
const [state, setState] = useState<T>()
useEffect(() => {
setTimeout(async () => {
setState(await loader())
})
}, [loader])
return state
}