do feed
This commit is contained in:
parent
2586dc87c8
commit
e84cf232a5
13 changed files with 605 additions and 139 deletions
13
src/hooks/useAsyncData.ts
Normal file
13
src/hooks/useAsyncData.ts
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue