Comments (18)
Original author: Shaun Michael Stone @shaunmichaelstone
Original date: 2017-12-23T23:00:50Z
Good article!
from marks-dev-blog-comments.
Original author: Einar Paul Qvale @einarpaulqvale
Original date: 2017-12-24T10:19:24Z
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?
from marks-dev-blog-comments.
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.
from marks-dev-blog-comments.
Original author: Einar Paul Qvale @einarpaulqvale
Original date: 2017-12-24T16:43:55Z
I’ll take a look, thanks!
from marks-dev-blog-comments.
Original author: Cliff Stamp @cliff_stamp
Original date: 2018-01-10T04:18:54Z
Is it possible to connect reselect'ers (from createSelector) to the actual state so it is essentially a getter function on the state?
from marks-dev-blog-comments.
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...
- https://github.com/guillaum...
- https://github.com/blgm/red...
from marks-dev-blog-comments.
Original author: pavan kumar @pavanear
Original date: 2018-08-02T17:17:38Z
good article
from marks-dev-blog-comments.
Original author: Wama Software @reactnativedevelopment
Original date: 2018-11-22T06:41:40Z
Good Post ! I really bookmark this article..Thanks for sharing.
from marks-dev-blog-comments.
Original author: Bruce Wang @brucewar89
Original date: 2019-08-14T08:49:54Z
Nice
from marks-dev-blog-comments.
Original author: 김창현
Original date: 2019-08-16T06:28:04Z
love it
from marks-dev-blog-comments.
Original author: Ahmed Ayed
Original date: 2019-08-29T21:15:29Z
Very good article, thanks.
from marks-dev-blog-comments.
Original author: Cheng Qiu @chengqiu
Original date: 2020-02-16T11:33:54Z
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
```
const reselect = require('reselect');
let state = {
a: {
b: 10,
},
c: 12,
};
const state1 = state => {
console.log("calculate state1");
return state.a.b;
};
const state2 = state => {
console.log("calculate state2");
return state.c;
};
const getResult = reselect.createSelector(
state1,
state2,
function (result1, result2) {
console.log("aggregate");
return result1 + result2;
}
);
console.log(getResult(state));
// should not cause any recalculation
state.c = 123;
console.log(getResult(state));
//state has changed, causing recalculation
state = {...state};
console.log(getResult(state));
```
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.
from marks-dev-blog-comments.
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.
from marks-dev-blog-comments.
Original author: yanlee26 @yanfrank
Original date: 2020-07-10T05:39:02Z
112
from marks-dev-blog-comments.
Original author: Gourav Bajaj @gouravbajaj
Original date: 2020-08-23T07:59:34Z
Great Post! Very Useful piece of code for those who are new in coding! Thanks for sharing..
Thanks and Regards
Gourav Bajaj
Works at Website Development Company
from marks-dev-blog-comments.
Original author: Gourav Bajaj @gouravbajaj
Original date: 2020-08-23T09:11:02Z
Loved it!. Very Well Written and informative post for those who are new in development.
Thanks and Regards
Gourav Bajaj Works at SAM Web Studio
from marks-dev-blog-comments.
Original author: Gourav Bajaj @gouravbajaj
Original date: 2020-08-23T09:11:31Z
Loved it!. Very Well Written and informative post for those who are new in development.
Thanks and Regards
Gourav Bajaj Works at SAM Web Studio
from marks-dev-blog-comments.
Original author: ممدلی شوخ
Original date: 2020-10-02T12:05:55Z
I read your article and worked in my project but I can't fetch data from server.
can you see the code please? it is in stackoverflow.
code link
from marks-dev-blog-comments.
Related Issues (20)
- How Web Apps Work: AJAX, APIs, and Data Transfer HOT 4
- Blogged Answers: Why React Context is Not a "State Management" Tool (and Why It Doesn't Replace Redux) HOT 31
- Coding Career Advice: Using Git for Version Control Effectively HOT 3
- Presentation: JavaScript for Java Devs HOT 1
- Practical Redux, Part 11: Nested Data and Trees HOT 6
- Coding Career Advice: Searching and Evaluating Online Information Efficiently HOT 2
- Presentations: Learn Modern Redux Livestream HOT 1
- Blogged Answers: A Comparison of Redux Batching Techniques HOT 1
- Codebase Conversion: Migrating a MEAN AngularJS app to React, Next.js, and TypeScript HOT 1
- Blogged Answers: React, Redux, and Context Behavior HOT 3
- Idiomatic Redux: Designing the Redux Toolkit Listener Middleware HOT 10
- Presentations: Intro to React, Redux, and TypeScript (2020) HOT 1
- How Web Apps Work: JavaScript and the DOM HOT 4
- Reactathon 2022: The Evolution of Redux Async Logic HOT 4
- Blogged Answers: How I Estimate NPM Package Market Share (and how Redux usage compares to other libraries) HOT 1
- Presentations: Modern Redux with Redux Toolkit
- Blogged Answers: The Evolution of Redux Testing Approaches HOT 1
- Presentations: 2022 Podcasts
- Blogged Answers: My Experience Modernizing Packages to ESM HOT 10
- Practical Redux, Part 7: Form Change Handling, Data Editing, and Feature Reducers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marks-dev-blog-comments.