Created
September 27, 2020 17:27
-
-
Save simicd/3cdbce31f793692ef3ca4720f8121284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect, useCallback } from "react"; | |
// ... | |
export const useFetch = <T>({ url, init, processData }: RequestProps<T>) => { | |
// ... | |
// Define asynchronous function | |
const fetchApi = async () => { | |
// ... | |
}; | |
useEffect(() => { | |
// Call async function | |
fetchApi(); | |
// ... | |
}, [stringifiedUrl, stringifiedInit, processJson]); | |
return { data, fetchApi }; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment