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
2
votes
1 answer

What is wrong with my filter method on this selector?

It is always returning an empty array. It should only return ids and titles where the id of the drawsTRFormIdAndTitleSelector is === the transactionRequestFormId of the drawTRSelector export const idAndTitleSelector = createSelector( …
ghostagent151
  • 1,218
  • 2
  • 16
  • 33
2
votes
2 answers

Memoize Reselect selector output based on a single input selector instead of all

I have a Reselect selector that maps an array of chosen ids into objects from a normalized store. const activeObjectsSelector = createSelector( state => state.activeIds, state => state.objects.byId, (activeIds, objectsById) => activeIds.map(id…
Ryan Giglio
  • 1,085
  • 1
  • 14
  • 26
2
votes
1 answer

Memoizing a filtered array in Redux

I have the following selectors setup selectors.js const getNodeHistory = (state) => state.session.nodeHistory; const getUnit = (state, unit) => unit; export const selectNodeHistory = createSelector( [getNodeHistory, getUnit], (history,…
dottodot
  • 1,479
  • 1
  • 16
  • 24
2
votes
0 answers

Passing arguments to reselect createStructuredSelector

I am using createStructuredSelector from reselect so my code looks like: const mapStateToProps = createStructuredSelector({ event: makeSelectEvent(), relatedEvents: makeSelectRelatedEvents(), loading: makeSelectLoading(), error:…
Igor Shmukler
  • 1,742
  • 3
  • 15
  • 48
2
votes
1 answer

TypeScript type for return of Reselect Redux function?

Is it possible to define the return type of the createSelector function in Redux's Reselect? I couldn't figure this out from the official docs: https://github.com/reduxjs/reselect#q-are-there-typescript-typings This cheatsheet also doesn't seem to…
Evanss
  • 23,390
  • 94
  • 282
  • 505
2
votes
2 answers

Using reselect with a date field on an object-based reducer

I have a simple task list app. One of the screens is a "Today & Overdue" list. The tasks reducer looks like: { "data": { 123: { "id": 123, "summary": "blah blah", "dueDate": "2020-03-12", "completed":…
Brian Weinreich
  • 7,692
  • 8
  • 35
  • 59
2
votes
1 answer

reselect using useSelector react-redux hook - state is not defined

I'm having an issue integrating reselect when using react-redux's useSelector hook. For some reason, the state in my selector is always undefined. I reproduced it in this sandbox. (Take a look at the Simple.js component). The state is fine in the…
Uri Klar
  • 3,800
  • 3
  • 37
  • 75
2
votes
0 answers

Redux re-renders entire table after any Firestore entry change (React-Redux-Firebase + React-Virtualized)

I'm using react-redux-firebase with reselect and react-virtualized to try and display a 500~ item list that will have entries that will change, get added or get deleted in the background. Every time a single entry changes on firebase, my table…
user5786934
2
votes
0 answers

What's the correct pattern for Immutable and Reselect?

Let's say I have the following code and let's say state is from Redux and for some reason state is not yet an Immutable.js object. The problem just cascades and becomes so verbose. export const helloWorldSelector = createSelector( initialState, …
Strawberry
  • 66,024
  • 56
  • 149
  • 197
2
votes
0 answers

What is the best way to evade reading property of undefined error using reselect with redux?

To display the page for user fast i must to show it before i fetches data if the page was refreshed. Selecting data from store can throw error like "reading property of undefined". To evade it i just use lodash get and it handles that error and…
Bash Lord
  • 127
  • 1
  • 10
2
votes
1 answer

How to test with the reselect createSelector function in jest?

Hello I'm trying to test the createSelector function in jest but I'm stuck. So the problem is that never enters in the if of the function getContent and I need to enter, for the coverage. File export const selectDetailsObject = createSelector( …
Jonathan
  • 469
  • 1
  • 6
  • 20
2
votes
1 answer

Do separate calls to createSelector with same inputs create multiple memoized results?

When we initially set up our new React project and decided on using Re-Select to memoize our selectors, a pattern was chosen to create wrapper functions around the calls to createSelector() in order to potentially parameterize some of the…
Joshua Barker
  • 987
  • 2
  • 11
  • 23
2
votes
0 answers

Reselect with an array causing component to always render

I'm using reselect to query my state and props. When I add a log statement to my component, I can see that it is being rendered over and over again. If I return a find (non-array, one object) from the getFiltered method I see that it doesn't render…
Sebastian Patten
  • 7,157
  • 4
  • 45
  • 51
2
votes
2 answers

react-redux + reselect + immutable.js call to many connects (performance)

Not so long ago, I started working with react, and I have a performance problem. I use react + redux + reselect + immutable.js. I have a lot data (like big table with data ~10mb). My problem is: when I have ~10 000 rows, react creates 10 000…
mixalbl4
  • 3,507
  • 1
  • 30
  • 44
2
votes
1 answer

reselect: pass multiple parameters to composed selector

I created a selector that is composed of two other selectors: export const getAvailableFilters = createSelector( getOpenedFilterMenu, isSaleCategory, (filterMenu, isSale) => { // .... doing stuff }, ); The getOpenedFilterMenu as well as…
Johannes Klauß
  • 10,676
  • 16
  • 68
  • 122