Skip to content

akshaykamath45/React-Query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Query

Understanding React Query in detail.It is a better method fetch data from API in React.I did not focus much on CSS in this part.

API's used :
https://catfact.ninja/fact

  • Queries is just the READ from CRUD.

  • Mutations is CUD from CRUD.

  • useQuery is a hook that takes in an array of arguments and returns an object with the data, error, and status of the query,The empty array is the key for the query.

  • We don't need any state to store the data, so we can use the useQuery hook to fetch the data from the API and store it in the data variable.

  • We don't have to update the state manually, we can use the refetch function to update the data.


Attaching some sample screen shots :

Generating Random Cat Facts on Clicking Update Data
image

Working Link