Skip to content

Future of Memoization

Alright, so now that you've learned all about the different optimization tools in our toolbelt, you might be wondering: going forwards, when should we use these tools? How do we know if a component should be made pure, or a calculation should be memoized?

Well, it's an interesting time to be asking these sorts of questions. 😅

Over the past couple of years, the React team has been working on a compiler with the codename “React Forget”. This compiler will automatically apply all the memoization tactics we've learned about. In theory, this means that we can delegate all of these concerns to the compiler, and not have to worry about it ourselves.

This compiler has not yet been released, but as of March 2023, they've begun testing it in production on certain parts of facebook.com.

Now, it's possible that this compiler will never ship. Maybe they'll discover some critical flaw with the idea. But given that they're already using it in production, I'm pretty confident that it'll work out.

And so, here's my recommendation: let's put memoization on the back burner for now. Unless you're currently working on a large React application that has noticeable performance problems, you don't really need to memoize anything, and it's possible that by the time you do get there, it'll be moot, since the compiler will do it for us.

So why did we even cover all of this stuff then?! Well, even with React Forget, it'll still be important to understand how React's render cycle works, including the role that memoization plays.

Whether we're the ones writing React.useMemo() in the future, or they're applied automatically when our app is compiled, the behaviour in-browser will be the same. We need to understand how it works, so that we can understand and debug our applications!

(Also, memoization comes up frequently in React job interviews! Being able to answer questions about what React.useMemo() does might help you land a job.)

If you'd like to learn more about React Forget, Meta developer Xuan Huang covered it in-depth in his conference talk “React without memo”.