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

Get last 2 elements of an array in a selector (Redux)

An array starts as [] and then keeps growing with numbers being added to it. I'm trying to create a selector to extract the last 2 elements of the array. I've got the following: const getHistory = (state) => state.score.history; export const…
Wasteland
  • 4,889
  • 14
  • 45
  • 91
0
votes
1 answer

How to use reselect in react-boilerplate

I am using react-boilerplate , and I am building a small kind of project so that I can understand the use of selectors. I watched this video which I enjoyed a lot and I believe I have a clear understanding of where I should use selectors. So what…
0
votes
0 answers

How to log the program flow of a very deep and complex functional JavaScript code?

I'm trying to understand the flow of the functions in this reselect library. I currently use console.log to log the output. Still, it is hard to understand the flow. Make me think how complex functional programming is!!! How can I intercept the…
wonderful world
  • 10,969
  • 20
  • 97
  • 194
0
votes
1 answer

Redux - selectors not accessing state

I've started learning selectors and redux. The state of the app looks as follows: And then unfolded: I'm trying to add a selector that would count the total of the sub-array first elements eg(6 + 4 + ..., etc), but first things first: I've started…
Wasteland
  • 4,889
  • 14
  • 45
  • 91
0
votes
1 answer

Redux state: action or selector?

The state gets hydrated by a function that randomly creates an array of numbers (+ 0) as follows: [[3, 0], [6, 0], [8, 0], [2, 0].....] and that's the app's state at the moment. [3, 0] is an example of a tile containing number 3 and being invisible…
Wasteland
  • 4,889
  • 14
  • 45
  • 91
0
votes
1 answer

How to test a `select(reselectSelector)` with jasmine?

I'm creating a React application and use react-boilerplate as my base project. After getting my head around Redux, Sagas and reselect and got my first components running, I'd like to write the corresponding unit tests. But unfortunately I'm not able…
Oliver
  • 43,366
  • 8
  • 94
  • 151
0
votes
1 answer

How to avoid potentially expensive re-calculating of computed properties with redux

Say I have animals in a redux store. It's a normalized object, the key is the id and the value is the object itself. Each animal has a key is_dog. animals: { 'id1': { location: 'foo', is_dog: true, name: 'Dog1' }, 'id2': { location: 'foo',…
Drew Schuster
  • 2,521
  • 12
  • 15
0
votes
0 answers

Idiomatic way to chain redux state changes?

I'm trying to figure out the idiomatic way to address this: I have a reducer that contains a list of “applied filters” and a list of “records”. When I change the filters or records, a list of “filtered records” should also change, but applying the…
0
votes
1 answer

Why does this test on a selector (reselect library) fail?

As per the title of the question. .../selector.js const makeSelectUserData = () => createSelector( selectProfile, (profileState) => profileState.get('userData') ); .../tests/selectors.test.js it('should select the current user', () => { …
dragonmnl
  • 14,578
  • 33
  • 84
  • 129
0
votes
1 answer

React reselect - toJS is not a function

I am getting an error in the selectors of a react application when using toJS with the reselect library. I tried importing toJS as well as not importing it and I get the error no matter what. nodeCreationWindow.get(...).toJS is not a…
Grzes Slania
  • 588
  • 1
  • 11
  • 28
0
votes
2 answers

Rendering a component based on dynamic route params with mapStateToProps and reselect

I am storing data for various rooms in a global app container. I have a sub-container called roomDetails that uses a reselect selector to select a room from the global state using ownProps.params.slug. This is done using mapStateToProps. My problem…
Dillon S.
  • 3
  • 2
0
votes
1 answer

Accessing a selector value in ReactJS with ImmutableJS

I am using a memoized selector via the react reselect library and I'm having trouble accessing the state value to see if it's set or not. I would like to be able to do something like this to check: const room = selectRoomById('roomId1'); if (room)…
Dillon S.
  • 3
  • 2
0
votes
4 answers

Undefined State Reselect Js

I am getting the following error: substate is undefined. However, I am not sure why substate would be undefined in my selector. Could someone please help me figure out what might be going wrong? Selector: import { createSelector } from…
Turtle
  • 1,369
  • 1
  • 17
  • 32
0
votes
1 answer

React redux container with createselector that contains a promise

I have a container that connects to the store, which is updated every second: return ({ match, ui }, { matchId }) => ({ value: match.getIn([matchId, 'masterCurrentTime'], 0), // about every second min: ui.get('seekStart'), max:…
Swift
  • 166
  • 2
  • 16
0
votes
2 answers

Immutable, why does my nested object using fromJS are not immutable when I use reselect

I have a bug with immutablejs and reselect. I have the following redux store in my reactjs application : /* * The reducer takes care of our data * Using actions, we can change our application state * To add a new action, add it to the switch…
Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
1 2 3
25
26