mirror of
https://github.com/cupcakearmy/obolus.git
synced 2024-12-22 16:16:27 +00:00
don't run the first time, only when refresh called
This commit is contained in:
parent
44549d77ed
commit
55adfdf587
@ -29,16 +29,17 @@ export const callAPI = async (ctxOrNull, { url, method, data }) => {
|
||||
else return response.data.body
|
||||
}
|
||||
|
||||
export const useCallAPI = (call) => {
|
||||
export const useCallAPI = (call, automatic = false) => {
|
||||
const [data, setData] = useState(undefined)
|
||||
|
||||
const refresh = () => {
|
||||
callAPI(null, call).then(setData)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
refresh()
|
||||
}, [0])
|
||||
if (automatic)
|
||||
useEffect(() => {
|
||||
refresh()
|
||||
}, [0])
|
||||
|
||||
return [data, refresh]
|
||||
}
|
Loading…
Reference in New Issue
Block a user