Coder Social home page Coder Social logo

Comments (4)

markerikson avatar markerikson commented on June 25, 2024

That sounds like things are working as expected:

  • All arguments get passed to all input selectors
  • Any new reference causes the reference comparisons to fail and that level of memoization to be recalculated

So yes, passing a new object reference to a selector is not a good idea. Have you tried passing them as separate arguments instead? selector(state, prop1, prop2).

from reselect.

misha-erm avatar misha-erm commented on June 25, 2024

Have you tried passing them as separate arguments instead? selector(state, prop1, prop2).

That's what we are migrating to right now. But this still doesn't solve the original issue. I understand why it works like that but many devs at first were a bit lost when I told them about first level of cache cascade and that prop selectors ideally should be written like

createSelector([(state) => getSchema(state), (state) => getSmthFromState(state), (state, prop1) => prop1], () => {})

instead of passing input selectors directly

createSelector([getSchema, getSmthFromState, (state, prop1) => prop1], () => {})

So what do you think, is it something that should be handled by the library? E.g. one more input dev check, note in docs or a solution?

from reselect.

markerikson avatar markerikson commented on June 25, 2024

I don't think there's anything we should change here.

Relying on function.length is always tricky, and it's not something I'd want to try to make use of in this case.

I think your best bet is to customize argsMemoize as needed for your situation.

from reselect.

misha-erm avatar misha-erm commented on June 25, 2024

Got it, thanks for your opinion 🙇🏻

Closing the issue then

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.