What is Memoization? How and When to Memoize in JavaScript and React
Hi everyone! In this article we will talk about memoization, an optimization technique that can help make heavy computation processes more efficient. We will start by talking about what memoization is and when it's best to implement it. Later on we will give practical examples for JavaScript and React. In programming, memoization is an optimization technique that makes applications more efficient and hence faster. It does this by storing computation results in cache, and retrieving that same information from the cache the next time it's needed instead of computing it again. In simpler words, it consists of storing in cache the output of a function, and making the function check if each required computation is in the cache before computing it. A cache is simply a temporary data store that holds data so that future requests for that data can be served faster. Memoization is a simple but powerful trick that can help speed up our code, especially when dealing with repetitive and heavy comp
German Cocca Hi everyone! In this article we will talk about memoization, an optimization technique that can help make heavy computation processes more efficient. We will start by talking about what memoization is and when it's best to implement it. Later on we will give practical examples for JavaScript and React. Table of Contents What is memoization How does memoization work JavaScript memoization example React memoization example Pure components PureComponent class Memo higher order component When to use the useCallback hook When to use the useMemo hook When to memoize Roundup What is Memo
Explore this link on the map →saved by
related reading
- Understanding useMemo and useCallback • Josh W. Comeaujoshwcomeau.com
- Why React Re-Renders • Josh W. Comeaujoshwcomeau.com
- useMemo – Reactreact.dev
- You Might Not Need an Effect – Reactreact.dev
- Pure components in React: Using PureComponent and React.memo - LogRocket Blogblog.logrocket.com
- Memoization - Wikipediaen.wikipedia.org
- useCallback – Reactreact.dev
- Blogged Answers: A (Mostly) Complete Guide to React Rendering Behavior · Mark's Dev Blogblog.isquaredsoftware.com
- How to write performant React code: rules, patterns, do's and don'ts | Developer Waydeveloperway.com
- React re-renders guide: everything, all at once | Developer Waydeveloperway.com
- When does React re-render components? | Felix Gerschaufelixgerschau.com
- Implementing React from scratchrob.directory