Why do I use React Query for OXINION and How?

To be honest, I thought bringing up React Query for my project is a bit over-engineering at the beginning. But more and more I visit my website, this is not what I wanted to experience. I wanted to fetch all content like Yelp.

My server was clearly giving me a sign why i had to use

According to MDN

“The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is a safe method, such as GET or HEAD, or when the request is conditional and uses an If-None-Match or an If-Modified-Since header.”

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is a safe method, such as GET or HEAD, or when the request is conditional and uses an If-None-Match or an If-Modified-Since header.

Why i choose React-Query over useEffect hook

  1. The order of work process

React Query: Starting to fetch first before component mount.

useEffect : Component mounted first and then started fetching.

2. Code readability

Its much clean to read than useEffect. So much state controlling like actual data, error, loading etc for useEffect

--

--

Investor & Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store