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.

Software Engineer at Target. I’m more active on twitter https://twitter.com/MalerbaAustin.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store