A lighter alternative to Redux: React Query

https://react-query.tanstack.com/

What is React Query

Server State vs. Client State

How can it replace Redux?

Queries

  • used forGET and POST methods, to retrieve data
  • React Query provides the useQuery hook that takes a unique key and a function that returns a promise
  • after storing data in cache with useQuery, you can access that data at any point with useQuery, which takes the unique key as an argument: const data = useQuery(‘unique key’)

Mutations

  • used for PATCH/PUT and DELETE methods, to modify data
  • React Query provides the useMutation hook

--

--

--

full-stack developer exploring how software can solve real-world problems | https://sarabastian.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why does Cloud look like Cumulonimbus!!

Learn Basic Access Modifiers in C #

Enterprise Chat News Round Up #21

Enterprise messaging industry news

Why You Can’t Replace REST with GraphQL

Discovering APIs: 10 must-haves before you set foot on land.

Real World Examples with Ballerina — Part II

Make coding faster on Android Studio with Templates — Part 2 (File and Code Templates)

File and Code templates

Add two numbers represented by linked lists

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
Sara Bastian

Sara Bastian

full-stack developer exploring how software can solve real-world problems | https://sarabastian.com/

More from Medium

Tips to build a Todo app with react, redux-saga, typescript and react-bootstrap — 1

Todo app with react + typescript + react-saga

The most popular web framework 2021 | React

An introduction to React Hooks

Custom React Api hook UT’s using Jest and RTL