Photo by Alexandru Acea on Unsplash

Although I have been using Redux to handle data fetching in many of my projects, I’ve always believed there must be a better way to do the same with React JS.

🤯 Why?

👎 Verbosity
Fetching data in Redux is a quite verbose process. Each fetch operation requires the developer to create:

  • three actions (fetch request, succeeded, failed)
  • three reducers (fetch request, succeeded, failed)
  • one middleware (usually redux-saga or redux-thunk)

Writing all this code takes a lot of time, even for a simple API call. Moreover, it’s not hard to end up with a big JS bundle.

👎 Over usage of Redux…


Photo by Blake Connally on Unsplash

A common mistake is to believe that a React component is smart enough to understand whether it needs to render itself again or not, based on its own props and state. But that’s not entirely the truth.

To better understand why, we should start by learning about the limitations of a non-pure React component by looking at two examples. After that, it will be easier to grasp the benefits of PureComponent and React.memo() by looking at two other examples.

A short summary of what’s coming:

  • Example 1 — Two Class Components
  • The Reconciliation
  • Example 2 — Two Function Components with…

Davide Cantelli

Software developer, passionate photographer, design lover and tireless dreamer

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