Skip to content

Instantly share code, notes, and snippets.

View jagretz's full-sized avatar
🎯
Focusing

Jason Gretz jagretz

🎯
Focusing
View GitHub Profile
@abhiaiyer91
abhiaiyer91 / reduxSelectorPattern.md
Last active July 7, 2024 13:03
Redux Selector Pattern

Redux Selector Pattern

Imagine we have a reducer to control a list of items:

function listOfItems(state: Array<Object> = [], action: Object = {}): Array<Object> {
  switch(action.type) {
    case 'SHOW_ALL_ITEMS':
      return action.data.items
    default: