Moving the functionality into a function, we get a custom hook: CodeSandBox: Custom hook (JS)
Generalize useFetch: Add error and re-invoke with setUrl function:
-
Let's generalize the
useFetchhook and allow new urls to be fetched with a function. -
Insight:
setUrlis basically adoFetch. -
Question: Why does hook not refetch?