Better Programming

Advice for programmers.

Follow publication

Member-only story

Exploring Caching Techniques in React

Gerard van der Put
Better Programming
Published in
7 min readFeb 11, 2021

Components and their information
What we will create today! Photo by the author.

Fetching data in React is one thing. Storing and caching this data is another story. The possibilities seem endless and the differences are often subtle, which makes choosing the right technique a bit of a hurdle sometimes.

Today, we’ll explore different techniques and look at all their details and subtleties. Should I use useMemo or memoization? Should I store data with useState and a context? When we’re done, you should be able to comfortably make informed choices with regards to caching data. You’ll learn about all the ins and outs.

And there are a lot of animated GIFs. What else could you wish for?

Let’s get started!

Our Data

Before we dive into the code, we can have a quick look at the data that we will be fetching in (most of) our components. The file that acts as our API looks like this:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Gerard van der Put
Gerard van der Put

Written by Gerard van der Put

Lead developer for a large industry-leading tech company. Support me! https://gerardvanderput.medium.com/membership.

Write a response