Before you go, check out these stories!

Hackernoon logoWhen You Should use Redux with APIs by@santiago-rodrig

When You Should use Redux with APIs

Author profile picture

@santiago-rodrigSantiago Andrés Rodríguez Márquez

Full-stack Developer, chess amateur, languages geek.

Have you been studying React and heard about Redux at some point, right? You get interested and start learning the concepts behind Redux, everything cool until now, but then you start working on a project that makes some API calls and you start wondering, when should I use Redux?

I was in the same situation not so long ago, Redux is great and everything, but you need to know how to use it effectively. When working with APIs you usually want your users to be able to filter the data they receive in some way, and that's where Redux shines, at filtering data!

What you really want is to store the data received from the API in a transitory warehouse, and this transitory warehouse is called Redux my friends, once the data is stored in the Redux state you can connect your React components to it, read the current filters and display the filtered information to the user.

If you encounter yourself in a situation where:

  1. You are working with React, Redux, and an API
  2. You want to filter the data you receive from the API somehow
  3. Don't know what to do with Redux once you have the data from the API

Then you better store that data in the Redux store using a dedicated state and define some filters state too, then you just filter the data in the Redux state using the defined filters.

I hope it helps somehow to any developer learning React and Redux.

I'm Santiago Rodríguez, a Full-stack Web Developer specialized in Ruby on Rails and connoisseur of React and Redux, if you want to get in touch just send me an email. | GitHub | LinkedIn


Become a Hackolyte

Level up your reading game by joining Hacker Noon now!