Questions tagged [reselect]

Reselect is a selector library for Redux.

Reselect is a selector library which uses memoization. It was originally written to compute derived data from -like applications state, but it's not strictly coupled to any specific architecture/library.

Reselect keeps a copy of the last inputs/outputs of the last call, and recomputes the result ONLY IF one of the inputs changes. If the the same inputs are provided twice in a row, Reselect return the cached saved output.

Reselect's memoization and caching are fully customizable.


Resources

387 questions
9
votes
0 answers

Avoid re-rendering components using array.map with React+Redux

First of all, I have already gone through: /react-redux/issues/779 Stackoverflow / React Redux rerenders when creating arrays Stackoverflow / How to deal with relational data in redux? Redux / Recipes / Managing normalized data And have learnt a…
peguerosdc
  • 946
  • 11
  • 21
9
votes
3 answers

How to nest Reselect selectors?

I have a selector that returns an array. The elements in the array themselves have derived data. I essentially need a recursive memoization selector that returns a derived array composed of derived elements. my current attempt is: export const…
kevzettler
  • 4,783
  • 15
  • 58
  • 103
9
votes
3 answers

How is state passed to selectors in a react-redux app?

I came across an example, where the mapStateToProps function is using memoization. I was just wondering how the "state" parameter is passed onto memoized selectors. After looking at the docs for reselect as well as redux, it seems that the…
krikey
  • 195
  • 1
  • 2
  • 11
8
votes
2 answers

Redux Selector not triggering when I'm calling it from mapstatetoprops

Now I'm working in react-redux. I'm trying to get questions from state one-by-one. Generated unique ID to store the questions in the state, after user submits,answer also store with the question. Uniqueid: { Question: question goes here, …
satheesh
  • 403
  • 5
  • 15
8
votes
2 answers

Redux normalizr - nested API responses

How can I use normalizr to deal with nested standardised JSON API responses that are key via the { data: ... } standard? For example a Book { data: { title: 'Lord of the Rings', pages: 9250, publisher: { data:…
AndrewMcLagan
  • 13,459
  • 23
  • 91
  • 158
7
votes
1 answer

How to define a version of createSelector typed for my app?

In redux-toolkit docs they suggest you to create the following definition to have proper types when you use useSelector hook: export const useAppSelector: TypedUseSelectorHook = useSelector; This will save you of having to type all the…
7
votes
2 answers

How does Redux Reselect memoization work?

I am trying to integrate reselect into my current app and as always , first i begin to read documentation and then if it needed , another recources.I couldn't understand one special part of documentation and also couldn't find recources which would…
Norayr Ghukasyan
  • 1,298
  • 1
  • 14
  • 28
7
votes
1 answer

Assign correct types to Reselect createSelector function

Edit: added package.json excerpt I am trying to implement typescript in an existing React project and I am facing difficulties with Reselect library. Typescript compiler insists on importing the first definition of createSelector function and fails…
Tristan Hamel
  • 131
  • 1
  • 2
  • 6
7
votes
2 answers

Compare & contrast redux reselect vs lodash / underscore memoize...?

I was wondering if someone can compare & contrast the differences between redux reselect lib vs lodash memoize...?
born2net
  • 24,129
  • 22
  • 65
  • 104
7
votes
1 answer

Access react router state in selector

I am moving a part of my app's state from the store to the URL. I am currently using redux to manage my app's state along with reselect to create selectors. The selectors compute derived values from the state in the redux store (in principal, this…
Tom Fenech
  • 72,334
  • 12
  • 107
  • 141
7
votes
3 answers

How to avoid React re-renders when using reselect to compute derived state

I'm using the ultimate combination of React + Redux + Reselect + Immutable.js in my application. I like the idea of reselect because it lets me keep my state (maintained by the reducers) as simple as possible. I use a selector to calculate the…
tobik
  • 7,098
  • 7
  • 41
  • 53
6
votes
2 answers

How can I memoize a variable derived from redux useSelector?

How can I memoize my rawTranscript variable so it doesn't trigger the useEffect below which subsequently triggers the expensive transcriptParser function? I've been trying a lot of different approaches, but the fact that I am using a redux-hook…
kevin
  • 2,707
  • 4
  • 26
  • 58
6
votes
1 answer

How to create a custom equality function with reselect and Typescript?

A standard reselect selector invalidates its memoized value and recomputes it if the input selectors fail a strict equality check: export const selectEmailsFromComments = createSelector( selectComments, // returns an array of comments comments…
Tom
  • 8,536
  • 31
  • 133
  • 232
6
votes
0 answers

How to Memoize (Deep Compare) Redux Objects Using Reselect with createSelectorCreator()?

The Situation Using react redux, in mapStateToProps for one of my container components, I pass down an object with 8+ keys for the sake of convenience. (I am aware that passing objects down is an anti-pattern, but the convenience of passing a…
gpsugy
  • 1,199
  • 1
  • 11
  • 25
6
votes
3 answers

How to use redux-form with reselect

I want to use the reselect with redux-form to get the value from redux. the problem is I don't know how to combine the getFormValues with reselect. it seems that I cannot access the state in the createSelector. so that I cannot come up a way to use…
leuction
  • 563
  • 2
  • 8
  • 19
1
2
3
25 26