Skip to content

Instantly share code, notes, and snippets.

@reime005
Last active Oct 25, 2020
Embed
What would you like to do?
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