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

Redux Reselect - selector with argument input is recalculating

I have the following selector: const getAllAddresses = (withStartEnd) => createSelector( [getAllAddressesSelector, getStartAddressSelector, getEndAddressSelector], (all, startAddress, endAddress) => { if…
Asaf
  • 2,158
  • 2
  • 25
  • 40
2
votes
1 answer

Testing Reselect Selectors

I am trying to test a react/redux reselect selector which will filter an array and return only active clients. My issue is with immutableJS. Selector: const selectClients = state => state.get('clients', initialState) const makeSelectInactiveClients…
Griffin M
  • 451
  • 4
  • 12
2
votes
2 answers

React Boilerplate: Dumb components re-render when the data in

I have a used react-boilerplate to setup the base for my project. Consider I have a container and 2 components(dumb components) like below, App - HomePage(Connected component with sidebarData and detailedData) - SideBar(data=sidebarData) …
Kamalakannan J
  • 2,818
  • 3
  • 23
  • 51
2
votes
1 answer

Reselect - use custom argument for second selector in createSelector

I have a following case: const firstSelector = (store, userId) => { ... }; const secondSelector = (store, moneyId) => { ... }; const selector = createSelector( firstSelector, secondSelector, // it doesn't accept `userId` but `moneyId` which…
Patrickkx
  • 1,740
  • 7
  • 31
  • 60
2
votes
2 answers

Redux: Update parent component data after child operations

I have some data loaded in the store after initial Axios call. Then I render two components match (parent component) and player (child component). This is the way to show the two components in a related way (this is a simplified example from my…
kurtko
  • 1,978
  • 4
  • 30
  • 47
2
votes
1 answer

Why does React-boilerplate selector.js export methods which call createSelector instead of exporting selector directly?

I'm using react-boilerplate which in turn uses reselect. I've noticed their use of reselect is a bit different then how reselect is documented. In fact I would have thought that it was defeating the advantage of reselect if not for the fact that…
dsollen
  • 6,046
  • 6
  • 43
  • 84
2
votes
2 answers

reselect CreateStructuredSelector difference in properties

Maybe this is not necessarily a reselect question const makeSelectError = () => createSelector( selectGlobal, (globalState) => globalState.get('error') ); and in reselect we use const mapStateToProps = createStructuredSelector({ error:…
Maru
  • 41
  • 2
  • 7
2
votes
2 answers

Reselect and recursive selector

I have a redux state with a tree of items (normalized) like: state = { items: [ { id: 1, parent: null, children: [2, 3] }, { id: 2, parent: 1, children: [4] }, { id: 3, parent: 1, children: [], value: 10 }, { id: 4, parent: 2,…
Frédéric Mascaro
  • 520
  • 1
  • 4
  • 17
2
votes
0 answers

Preventing reselect re-computing until all data actions are complete

I have a Redux (well, rxjs-store) structure that's very generic. Basically, my data-types are all different versions of a generic data structure called an "Element" (each defined by a different "ElementType"). The goal is I don't have to add a whole…
Joe
  • 6,773
  • 2
  • 47
  • 81
2
votes
0 answers

React Boilerplate Performance Issues

I'm dealing with some performance issues. When I have ImmutableJS map of ~40 elements, shown as checkboxes, when toggling a checkbox (via redux) dev tools throws me a violation info: [Violation] 'click' handler took 231ms Is this because I badly…
2
votes
1 answer

Redux / Reselect - selector reusing

I am new to selectors. I have created the following ones: import { createSelector } from 'reselect'; const getValues = (state) => state.grid; // [3, 4, 7, 3, 2, 7, 3,...] const getTiles = (state) => state.tiles; // [0, 1, 0, 1, 0, 0, 1,...] //…
Wasteland
  • 4,889
  • 14
  • 45
  • 91
2
votes
1 answer

Is it possible to create a selector that accesses multiple branches of the state tree?

I am working on a Redux project with a bunch of reducers that are combined const rootReducer = combineReducers({ reducer1, reducer2, ... }); The reducers each update a branch of the store sampleStore = { reducer1: {a1: 7, b1: 5,…
Ben S
  • 778
  • 1
  • 5
  • 19
2
votes
1 answer

How does ngrx store.select method pass the store context?

In this ngrx example component, on line 27, you will see this.books$ = store.select(fromRoot.getSearchResults); The selector function getSearchResults is composed of other selector functions and the innermost selector functions are getSearchState…
wonderful world
  • 10,969
  • 20
  • 97
  • 194
2
votes
0 answers

ngrx reselect Selector createSelector load order (circular) dependencies

I've run into the following errors a couple times when I perform createSelector in file B using a Selector defined in file A... apparently the Selector defined in file A has not been instantiated and I get an undefined reference error... Error:…
Neoheurist
  • 3,183
  • 6
  • 37
  • 55
2
votes
1 answer

Ngrx all reselect selectors being run on single state slice change

import { GlobalState } from './app.reducer'; import * as App from './app.actions'; import { AppState } from './appstate'; import { createSelector } from 'reselect'; //Global Reducer State export interface GlobalState { search:…
MilindaD
  • 7,533
  • 9
  • 43
  • 63