Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between react-fetch and whatwg-fetch

Tags:

reactjs

fetch

I'm new to reactjs and I've been reading on how to get and post data from api. I've seen these two, but I'm not sure what to use and what's the difference between the two? I read it but I'm not sure what will I use. Thanks!

  • react-fetch
  • whatwg-fetch
like image 326
naru Avatar asked Nov 10 '16 08:11

naru


1 Answers

react-fetch allows you to use a component(JSX) instead of writing specific JS code. Under the hood, it uses the original fetch function(or isomorphic-fetch, not really relevant to your question).

I would suggest reading about fetch on MDN before getting to a decision.

Which should you use? Depends on your personal preferences. If you don't have any experience with fetch, I'd use whatwg-fetch to understand how it works better. Once you have a better understanding of it, you can then choose between the two libraries. If you have a simple AJAX request, consider using react-fetch. If the situation requires mutating state, or some other complex logic, I'd suggest using whatwg-fetch.

like image 74
Dor Weid Avatar answered Nov 10 '22 14:11

Dor Weid