Implement add user function

This commit is contained in:
2023-10-29 13:19:01 +07:00
parent 372e6819dd
commit 4f24d9c6e2
12 changed files with 149 additions and 40 deletions
+5 -2
View File
@@ -3,12 +3,15 @@ import { useEffect, useState } from 'react';
// Constants
import { BASE_URL } from '../constants/path';
export const useFetch = (path: string) => {
export const useFetch = (path: string, reload?: boolean) => {
const [data, setData] = useState(null);
const [isPending, setIsPending] = useState(false);
const [errorMsg, setErrorMsg] = useState<string | null>(null);
useEffect(() => {
// Clear data
setData(null);
const fetchData = async () => {
setIsPending(true);
@@ -31,6 +34,6 @@ export const useFetch = (path: string) => {
};
fetchData();
}, [path]);
}, [path, reload]);
return { data, isPending, errorMsg };
};