Giter Site home page Giter Site logo

Comments (3)

aryaemami59 avatar aryaemami59 commented on June 6, 2024 1

Correct me if I'm wrong but I believe you're asking "Can we use a memoized selector created using createSelector and pass it as an input selector to another selector that is being created with createSelector?" If that's the question, the answer is yes, it's part of what makes Reselect awesome. Composable memoized selectors!

const selectAdultUsers = createSelector([state => state.users], users =>
  users.filter(user => user.age > 18),
)

const selectAdultUsersIds = createSelector([selectAdultUsers], adultUsers =>
  adultUsers.map(adultUser => adultUser.id),
)

I believe what you're concerned about with regards to the specific scenario you've mentioned above, is that you're using an output selector like selectAB as in input selector for selectABC1 but since selectAB returns a new reference in its result function, you're worried that it might break memoization, well you can rest easy because it will not. In fact that is pretty much what composable selectors are supposed to look like. We put some dev mode checks in place to catch potential errors like the one you're concerned about, check your console output if you see there is nothing there after calling the output selector, then that should provide some reassurance that you're not going down the wrong path. And to get some even more reassurance you can always look at the docs as well.

from reselect.

cchaonie avatar cchaonie commented on June 6, 2024 1

@markerikson @aryaemami59 Really appreciate your answers. @aryaemami59 's answer is the one I needed exactly.

from reselect.

markerikson avatar markerikson commented on June 6, 2024

I'm not sure I understand the question. Both of those appear to be valid selector definitions. Can you clarify the question?

from reselect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.