You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation as written creates confusion around when and when not to use memoization. Specifically, the section Balance Selector Usage contains the following code:
// ❌ DO NOT memoize: will always return a consistent referenceconstselectTodos=state=>state.todosconstselectNestedValue=state=>state.some.deeply.nested.fieldconstselectTodoById=(state,todoId)=>state.todos[todoId]// ❌ DO NOT memoize: deriving data, but will return a consistent resultconstselectItemsTotal=state=>{returnstate.items.reduce((result,item)=>{returnresult+item.total},0)}constselectAllCompleted=state=>state.todos.every(todo=>todo.completed)
These examples seem to be explicitly discouraged, but you'd only know that by reading the entire doc. Based on the number of real-world examples I've seen of people memoizing simple lookups, I don't think many people are getting all the way to the bottom.
Could the docs be updated so that the examples follow best-practices? (I'm happy to open a PR if that's helpful.) Thanks!!
The text was updated successfully, but these errors were encountered:
The documentation as written creates confusion around when and when not to use memoization. Specifically, the section Balance Selector Usage contains the following code:
This makes sense to me! However, the Create Selector Overview shows the following examples:
These examples seem to be explicitly discouraged, but you'd only know that by reading the entire doc. Based on the number of real-world examples I've seen of people memoizing simple lookups, I don't think many people are getting all the way to the bottom.
Could the docs be updated so that the examples follow best-practices? (I'm happy to open a PR if that's helpful.) Thanks!!
The text was updated successfully, but these errors were encountered: