Chat bug fix and top name implementation

This commit is contained in:
2025-10-18 11:09:43 +02:00
parent 10d7b80c13
commit d878721098
5 changed files with 46 additions and 17 deletions
+16
View File
@@ -0,0 +1,16 @@
import { useEffect, useState } from "react";
export default function useAsync<T, E = any>(func: () => Promise<T>) {
const [loading, setLoading] = useState(true);
const [value, setValue] = useState<T>();
const [error, setError] = useState<E>();
useEffect(() => {
func()
.then(setValue)
.catch(setError)
.finally(() => setLoading(false));
}, []);
return { value, loading, error };
}