reselect icon indicating copy to clipboard operation
reselect copied to clipboard

Should selectors be composed with or without an array?

Open davegri opened this issue 9 years ago • 1 comments

I found the examples in the docs a bit confusing:

1)

const taxSelector = createSelector(
  subtotalSelector,
  taxPercentSelector,
  (subtotal, taxPercent) => subtotal * (taxPercent / 100)
)

2)

export const getVisibleTodos = createSelector(
  [ getVisibilityFilter, getTodos ],
  (visibilityFilter, todos) => {
    switch (visibilityFilter) {
      case 'SHOW_ALL':
        return todos
      case 'SHOW_COMPLETED':
        return todos.filter(t => t.completed)
      case 'SHOW_ACTIVE':
        return todos.filter(t => !t.completed)
    }
  }
)

Is there a difference between these two ways of composing selectors?

davegri avatar Dec 26 '16 14:12 davegri

No, there is no difference.

ellbee avatar Dec 31 '16 15:12 ellbee