import { useState } from "./state" ; export function useAsync < T > ( f , initial ) { const [ val , setVal ] = useState < { ret : T ; } > ( { ret : initial } ) ; setVal ( async ( ) => ( { ret : await f ( ) } ) ) ; return val . ret ; }