Created
April 4, 2020 16:43
-
-
Save hymm/65b6850fb83d30af5c04779e0a6e2c6a 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
| function useAbortController() { | |
| const ref = useRef(); | |
| useEffect(() => () => ref.current.abort(), []); | |
| return useCallback(() => { | |
| ref.current = new AbortController(); | |
| return ref.current.signal; | |
| }, []); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment