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

Reselect. React. Which is the best way of usage the Reselect to gets the maximum perfomance?

I'm not so far ago have met with new to me package as Reselect. I read carefully the official docs and already have an experience with my firsts selectors. But only one thing that I cannot understand - which is the best code architecture of…
Max Travis
  • 1,228
  • 4
  • 18
  • 41
3
votes
2 answers

Returning plain JS object from memoized selector using Immutable.js

I'm working on a React + redux + Immutable.js + reselect application. I'm considering a design where I'm using Immutable.js in the reducers and sagas, but don't want to couple this library with the smart components, so my presentational part of the…
jedzej
  • 422
  • 3
  • 12
3
votes
1 answer

React / Redux / Reselect - How to pass in argument, stored in local state to be used to filter data stored in redux store?

I am rendering data (having it in my redux store), I have a search bar and want to filter the data results based on the search input. I am using reselect library and cant seem to make it work. I read their documentation and Ive tried various things:…
javascript2016
  • 973
  • 3
  • 17
  • 41
3
votes
1 answer

Reactjs Redux:mapStateToProps not rendering the component on state change

I have search filter and sort inputs on the same component.I'm using reselect(selector package) where the data array is filtered and sorted. The mapStateToProps is updating the component on each search filter result.but the mapStateToProps is not…
CodeZombie
  • 2,027
  • 3
  • 16
  • 30
3
votes
1 answer

Detecting a hot reload in React Native

Is there a variable that exposes the ID / count of the current hot reload in React Native, or alternatively any other way of detecting a hot reload? For context, I have a dynamic require behind a reselect selector which doesn't get invalidated when…
Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
3
votes
2 answers

Issue with creating a reselect selector that takes a dynamic argument

I am trying to pass a dynamic argument to a reselect selector. The reason for this is that this argument is actually a angular route parameter that is not known in advance. It cannot be part of the state either. Here is the relevant code from the…
balteo
  • 23,602
  • 63
  • 219
  • 412
3
votes
1 answer

substate.get() is not a function using React Boilerplate

I have a component called Login, and these selectors: const selectLogin = () => (state) => state.get('login'); const selectUser = () => createSelector( selectLogin(), (loginState) => loginState.get('user') ); Here's what state looks like for…
James Bowler
  • 2,194
  • 2
  • 17
  • 23
3
votes
0 answers

Memoized selector update not triggering in composed selector

I'm using reselect for memoized selectors in a redux environment. Note in the readme for reselect that these selectors are composable - that is, one selector can be used by another. Here are my selectors: import { createSelector } from…
Scotty H
  • 6,432
  • 6
  • 41
  • 94
3
votes
2 answers

redux reselect selectors for relational data

selectors takes 2 arguments, state and props, but how can we handle selectors for relational data ? initialState = { department :{ids:[1],byId:{name:'dep 1',id:1,parent:null}} sections :{ids:[2],byId:{name:'section 1.1',id:2,parent:1}} …
Zalaboza
  • 8,899
  • 16
  • 77
  • 142
3
votes
1 answer

Reselect always re rendering

I'm trying to add reselect to my react code but it seems to be always rerendering. Everytime I change my state the console prints "testing" even though the input-selector is not changing. I created a simple test to show you guys whats…
Charles Haro
  • 1,866
  • 3
  • 22
  • 36
3
votes
0 answers

How to properly use an observable with Redux store and routing

Using the real-world example from Redux, where would one best define an observable and then listeners on the Redux store? For example from this Redux discussion thread, when utilizing redux-rx where should the following code be placed in the…
wphampton
  • 504
  • 5
  • 13
2
votes
2 answers

Is there a performance penalty when using closures to implement a memoized selector with Reselect?

I've got a question about selector memoization with Reselect. As far as I understand the documentation of Reselect, the following implementation is the proposed and correct way to memoize a selector that expects a parameter: const…
frehder
  • 88
  • 1
  • 7
2
votes
1 answer

Redux Toolkit RTK Query - Difference between useGetDomainsQuery VS api.endpoints.getDomains.initiate(args)

I want to make an API call with some params, and use the selectors to get that values in my components I am getting data in below implementation const { data, isLoading, isFetching, error } = useGetDomainsQuery({ search: search || '', …
Ayaz Sayyed
  • 123
  • 1
  • 1
  • 5
2
votes
2 answers

Is it safe to use hooks in createSelector?

I have just found out that I can use data hooks in createSelector functions and it works. An example: // This is a normal hook const useUserReducer = () => { const userAccessData = useSelector(state => state?.userAccessData) return…
Rashomon
  • 5,962
  • 4
  • 29
  • 67
2
votes
1 answer

How can I pass useParams to mapStateToProps in React with React Router v6?

In my application, I want to pass the parameter that I'm getting from useParams() to the mapStateToProps function which I'm using with the Reselect library. I can hard code the value instead of passing this parameter and everything works as…
Mahdyar
  • 181
  • 1
  • 11