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,13 +29,14 @@ export const callAPI = async (ctxOrNull, { url, method, data }) => {
|
|||||||
else return response.data.body
|
else return response.data.body
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useCallAPI = (call) => {
|
export const useCallAPI = (call, automatic = false) => {
|
||||||
const [data, setData] = useState(undefined)
|
const [data, setData] = useState(undefined)
|
||||||
|
|
||||||
const refresh = () => {
|
const refresh = () => {
|
||||||
callAPI(null, call).then(setData)
|
callAPI(null, call).then(setData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (automatic)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refresh()
|
refresh()
|
||||||
}, [0])
|
}, [0])
|
||||||
|
Loading…
Reference in New Issue
Block a user