2

Memoization in react (for example reselect) where thes memoized values are kept? Some cookie, local storage?

heisenberg7584
  • 563
  • 2
  • 10
  • 30
  • 2
    The memoized value will be stored in memory since it will be gone by the page refresh. – SMAKSS Jul 04 '20 at 13:27
  • 1
    JavaScript code gets saved in the memory of the browser process, not like cookies which will be save on the hard disk – adel Jul 04 '20 at 13:29
  • @adel so in session storage? – heisenberg7584 Jul 05 '20 at 07:27
  • @heisenberg7584 - no. `const x = 1`. Sets a variable that is stored "in memory" that is not in session storage. Your application code contains data, variables, functions, etc that is stored "in memory" - it exists only within the browser process. – Adam Jenkins Aug 30 '20 at 13:26

1 Answers1

1

Reselect stores its memoized values in memory.

Here is reselect's defaultMemoize source code where the variable lastResult points to the last returned result.

Andrea Carraro
  • 9,731
  • 5
  • 33
  • 57