Reselect: createStructuredSelector - what is the point?

Created on 11 Oct 2016  路  2Comments  路  Source: reduxjs/reselect

https://github.com/reactjs/reselect#createstructuredselectorinputselectors-selectorcreator--createselector

I'm curious what the intent of the method is. I thought reselect was supposed to help with performance optimizations, but not sure why one would create a reselect selector for a mapping that does no computations other than creating a new object. Are there performance gains from using memoization in such cases?

Thanks.

Most helpful comment

It's there purely for convenience. If you have selectors a, b, and c, createStructuredSelector means the difference between:

createSelector(a, b, c, (ax, bx, cx) => ({a: ax, b: bx: c: cx})

and:

createStructuredSelector({a, b, c})

All 2 comments

It's there purely for convenience. If you have selectors a, b, and c, createStructuredSelector means the difference between:

createSelector(a, b, c, (ax, bx, cx) => ({a: ax, b: bx: c: cx})

and:

createStructuredSelector({a, b, c})

I think the benefit is with composing selectors. It helps to reduce some boilerplate. It's not meant to be used by itself. Thanks.

Was this page helpful?
0 / 5 - 0 ratings