Last active
August 17, 2020 19:26
-
-
Save simicd/0154eea4334ccaba00802fd4d780ab3e 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 | |
| // ... | |
| }, [url, init]); // Add dependency list | |
| return data; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment