-
-
Save reime005/85db5f2aaf55dfbe8ed05c1c796af0f7 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 useAsyncEffect from '@n1ru4l/use-async-effect'; | |
useAsyncEffect( | |
function* (onCancel, c) { | |
const controller = new AbortController(); | |
onCancel(() => controller.abort()); | |
const data = yield* c(search(controller)); | |
}, | |
[searchValue], | |
); | |
const search = controller => fetch('someURL', { signal: controller.signal }).then(r => r.json()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment