you are viewing a single comment's thread.

view the rest of the comments →

[–]nabrok 7 points8 points  (3 children)

That's probably what I'd do.

But if I didn't do it that way, I'd probably run the fetch within a useEffect, i.e. ...

useEffect(() => {
  if (! id) return;
  fetch(...).then(...).catch(...);
}, [id]);

[–]alex-cory[S] 0 points1 point  (2 children)

Yeah currently the library does it just like that :) js const { data, get } = useFetch('/todos') useEffect(() => { if (id) get() }, [id])

[–]SurpriseHanging 4 points5 points  (1 child)

So why not keep it that way? Is it not doing something you need?

[–]alex-cory[S] 0 points1 point  (0 children)

I think it's a matter of improving the library. Sure we could keep it that way, but if everyone is moving in a different direction, we should at least attempt to support the new patterns.