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

Redux - pass ownProps argument to selector

I cannot pass variable ownProps from mapStateToProps to selector. My selector: export const nameSelector = createSelector( [ state => state.element.get('name') ], (name) => !name.trim() ); const mapStateToProps = (state,…
user
  • 4,410
  • 16
  • 57
  • 83
4
votes
1 answer

Select inter-dependant data in redux store with reselect createSelector

So, I am using redux, and reselect tool createSelector to memoize my selectors in mapStateToProps, and it is great. Now, I have some normalized data in my store, and a container that needs inter-dependant data from the store. I am doing this, for…
Pandaiolo
  • 11,165
  • 5
  • 38
  • 70
4
votes
1 answer

Redux State Using Reselect To Derive Related Data

I've been stuck on this for a while. Here's a part of my redux-state state: { teachers: [ { teacherId: 'ttt1', teacherName: 'Susan', isCool: true, teachesAt: 'sss1'}, { teacherId: 'ttt2', teacherName: 'Karen', isCool: false, teachesAt:…
Clay_F
  • 561
  • 1
  • 6
  • 17
4
votes
1 answer

How to test a Reselect selector from nested reducer?

I created a simple Redux selector with the Reselect library. The selector gets the last object in an array. In the Reselect docs, the testing example is built with Assert library rather than Expect library, but my app originates from React Create…
Kwhitejr
  • 2,206
  • 5
  • 29
  • 49
4
votes
3 answers

how to ignore ordering of reselect selectors when composing selectors

As I compose more selectors together, I'm finding that I'm reordering where the selectors are defined. For example, export const selectNav = state => state.nav; export const selectPage = state => state.page; export const selectNavAndPage =…
epikhighs
  • 458
  • 3
  • 14
3
votes
0 answers

Mocked selectors (reselect + jest) stopped working with Jest v.29 (upgraded from v.27)

I used to have a global file with all my selector mocks. It was a list of all my store selectors and looked like below: jest.mock('redux/mainData/selectors', () => ({ selectLoading: jest.fn(() => false), selectData: jest.fn(() => [{ id: '1'…
jake-ferguson
  • 315
  • 3
  • 11
  • 32
3
votes
2 answers

How to manage a selector that accepts arguments with yield select?

I have a React application where I'm using Redux and Redux-Saga and Reselect as selector library (with Immer to handle the immutability of the Redux state). I'm writing this question because I'd like to understand if my approach to handle the…
lucataglia
  • 728
  • 5
  • 18
3
votes
2 answers

A state mutation was detected between dispatches, Redux toolkit and selectors/reselect

I'm having some trouble regarding createSelector and async thunk. Basically I'm trying to retrieve a list of links, and sort them depending on how many clicks they have, from highest to lowest. Here is my simplified code. MainPage.tsx export const…
ffx292
  • 542
  • 12
  • 27
3
votes
1 answer

React/ Redux select filtering and sorting using selectors

I have a list of items that I would like the user to be able to sort and filter by attribute. I figure using selectors is the most efficient way to do this, though I am not sure exactly how? Ideally, I would like the user to select an attribute from…
Morks
  • 284
  • 3
  • 15
3
votes
3 answers

Reselect error: Selector creators expect all input-selectors to be functions

I'm trying to use reselect within my component: const test = useSelector(({ test }) => test); const testData = createSelector( test, items => console.log(items), ); I'm getting Error: Selector creators expect all input-selectors to be…
Murakami
  • 3,474
  • 7
  • 35
  • 89
3
votes
1 answer

How to use Reselect with nested selector calls

I have a large selector that loops over an array and calls a selector for each item in the array. Is there any easy way to manage this? It looks kind of like this: const memoizedGetPatientSymptomSeries = createSelector( state =>…
Swish
  • 359
  • 4
  • 14
3
votes
1 answer

Can not provide/test saga when using a reselect selector

I've been writing some redux-saga tests using redux-saga-test-plan but having some issues when trying to provide some selects to fake some values to the expectSaga test. It seems as though the provider isn't replacing our reselect function call with…
3
votes
2 answers

redux reselect is returning a function

For some strange weird reason my reselect selector is returning this function : ƒ () { if (!areArgumentsShallowlyEqual(equalityCheck, lastArgs, arguments)) { // apply arguments instead of spreading for performance. lastResult =…
Oliver Watkins
  • 12,575
  • 33
  • 119
  • 225
3
votes
2 answers

Call combined reselect selector from redux-saga

I am trying to call a combined selector from redux-saga. The idea is that I have two drop downs. Choices in first drop down will filter the appropriate values in second drop down, i.e. my combined selector will filter out some non relevant values,…
user1665355
  • 3,324
  • 8
  • 44
  • 84
3
votes
2 answers

Redux Selector for normalized state

I need help in creating the selectors for the state which is normalized based on the documentation from redux docs State { "entities": { "people": { "byId": { "1": { "name": "Test User 1", …
Vabs
  • 485
  • 1
  • 5
  • 17