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 asGET
orHEAD
, or when the request is conditional and uses anIf-None-Match
or anIf-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 asGET
orHEAD
, or when the request is conditional and uses anIf-None-Match
or anIf-Modified-Since
header.
Why i choose React-Query over useEffect hook
- 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