Created
August 16, 2020 18:22
-
-
Save simicd/3fa8d95a74a5ee12e852383d384da50d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // useFetch.ts | |
| // ... | |
| export const useFetch = ({ url, init }: RequestProps) => { | |
| // Response state | |
| const [data, setData] = useState<DogImageType>(); | |
| useEffect(() => { | |
| // Define asynchronous function | |
| const fetchApi = async () => { | |
| // ... | |
| }; | |
| // Call async function | |
| fetchApi(); | |
| }, []); | |
| return data; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment