Skip to content

Commit 30f1067

Browse files
Merge pull request #1 from PraSoonGosWami/main
feat: added user passable dependency array
2 parents 93efd1a + e7547fe commit 30f1067

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/useFetch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from "react";
22

3-
const useFetch = (url, initalData) => {
3+
const useFetch = (url, initalData, dependeices = []) => {
44
const [data, setData] = useState(initalData);
55
const [loading, setLoading] = useState(false);
66
const [error, setError] = useState(false);
@@ -17,7 +17,7 @@ const useFetch = (url, initalData) => {
1717
setError(true);
1818
})
1919
.finally(() => setLoading(false));
20-
}, []);
20+
}, dependeices);
2121

2222
return { data, loading, error };
2323
};

0 commit comments

Comments
 (0)