Austin Malerba
1 min readJul 23, 2019

--

I’d recommend using reselect to memoize your selector logic. Here’s the todos example modified to use a memoized selector when getting the list of filtered todos https://codesandbox.io/s/todos-useapi-nsh3g?fontsize=14&module=%2Fsrc%2Fstores%2FtodosStore.js . filterTodos contains a console log statement that logs whenever the function is invoked. You can see that with memoization if you increment the unrelatedState, the filterTodos function will not be invoked because getVisibleTodos is memoized and because it does not depend on the unrelatedState.

--

--

Austin Malerba
Austin Malerba

No responses yet