Comments (3)
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.
@markerikson @aryaemami59 Really appreciate your answers. @aryaemami59 's answer is the one I needed exactly.
from reselect.
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)
- unstable_autotrackMemoize Errors HOT 1
- How to type redux state and selectors with readonly? HOT 3
- Consider dev mode checks for `x => x` result functions HOT 2
- More Reselect addons to investigate HOT 1
- Add identifiable information to dev mode check log messages HOT 3
- Documentation ignores links in the table of contents entries HOT 1
- Type loss in `createSelector` with inline function declarations passed as separate arguments
- lastResult.deref is not a function (it is undefined) HOT 6
- Better call stack for selector warnings HOT 11
- Unable to use `resultEqualityCheck` with `weakMapMemoize` HOT 3
- Incorrect weakMapMemoize alternative example using useCallback HOT 1
- using createSelector.withTypes prevents build HOT 7
- Question: Why can't we support `createAsyncSelector`? HOT 7
- TypeError: (0 , _reselect.createSelector) is not a function HOT 12
- `weakMapMemoize` with `resultEqualityCheck` is provided empty objects for first call. HOT 3
- Library do not work in Safari < 14.1 HOT 1
- Why the LRUCache implementation is using Array over the Doubly Linked List with Map? HOT 8
- Current documentration loose article about passing parameters HOT 1
- First level of cascading memoization is broken when more props are passed HOT 4
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 reselect.