-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idiomatic Redux: Using Reselect Selectors for Encapsulation and Performance #24
Comments
Original author: Shaun Michael Stone @shaunmichaelstone Good article! |
Original author: Einar Paul Qvale @einarpaulqvale Great article. Personally find that inadvertent renders due to returning new refs from selectors (using map/filter/reduce, or spread operator) is probably a good enough reason to use reselect in itself, at least I’ve seen that mistake made a lot (and made it myself). One question. As you say it’s common to co-locate selectors with the reducer that it selects from, but where would you recommend placing a selector that has input selectors from different slices of the store? Perhaps just a “selectors” file that imports the different input selectors from the different reducers? |
Original date: 2017-12-24T16:36:28Z I'm generally not concerned with trying to make my feature folders totally encapsulated from interacting with other parts of the codebase. I mostly just want to easily know where I can find a given piece of code. If a reducer or selector needs to reference an action type or slice of state that "belongs" to another feature, I'm fine with that. Your mileage may vary on that, of course. If you _are_ trying to keep your app's features more encapsulated, then a dependency injection type approach may be more useful. See Randy Coulman's posts on "globalizing selectors" that I linked at the end of the post for some good suggestions. |
Original author: Einar Paul Qvale @einarpaulqvale I’ll take a look, thanks! |
Original author: Cliff Stamp @cliff_stamp Is it possible to connect reselect'ers (from createSelector) to the actual state so it is essentially a getter function on the state? |
Original date: 2018-01-10T04:38:03Z Not out of the box with Reselect, no. Selectors are built with the assumption that you're passing in the current state tree as a parameter. I _have_ seen a couple libs that claim to let you add selectors to the store itself or embedded in the state tree. You might take a look to see of any of them are close to what you want: - https://github.com/luwes/re... |
Original author: pavan kumar @pavanear good article |
Original author: Wama Software @reactnativedevelopment Good Post ! I really bookmark this article..Thanks for sharing. |
Original author: Bruce Wang @brucewar89 Nice |
Original author: 김창현 love it |
Original author: Ahmed Ayed Very good article, thanks. |
Original author: Cheng Qiu @chengqiu I have one doubt, selectFilteredSortedTransformedData only recalculates if its unique parameter "state" changes, however, the change of "state.someData" does not change "state" at all, which results in selectFilteredSortedTransformedData giving the same cached value. Here is my justification let state = { const state1 = state => { const getResult = reselect.createSelector( console.log(getResult(state)); //state has changed, causing recalculation ``` I think the true reason why it works in redux is because "combineReducers" returns a brand new state object every time any action got dispatched. |
Original date: 2020-02-16T16:58:35Z I think you're misunderstanding how Reselect works. It doesn't matter if the top `state` parameter has changed. What matters is if any of the values returned by the "input selectors" have changed. |
Original author: yanlee26 @yanfrank 112 |
Original author: Gourav Bajaj @gouravbajaj Great Post! Very Useful piece of code for those who are new in coding! Thanks for sharing.. |
Original author: Gourav Bajaj @gouravbajaj Loved it!. Very Well Written and informative post for those who are new in development. |
Original author: Gourav Bajaj @gouravbajaj Loved it!. Very Well Written and informative post for those who are new in development. |
Original author: ممدلی شوخ I read your article and worked in my project but I can't fetch data from server. |
No description provided.
The text was updated successfully, but these errors were encountered: