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
0 answers

useSelector dosen't seem to be updated immediately due to reducer state changing

I have a structure(nested object) that exists in the attached image and if I want to change the value of info‍‍[1] and assign it to info state into the related reducer, but it doesn't update immediately and I think a deep comparison between the…
2
votes
1 answer

How can I access useParams value inside redux selector as ownProps

I am using "reselect" library in redux to get the data. I wanna get data based on useParams() hook and then to pass it inside mapStatetoProps as ownProps and then to selectionCollection function which is a selector and accepts the value of…
Mr.Z
  • 23
  • 4
2
votes
2 answers

How do I pass a URL Param to a selector

I recive a url param from useParams. I want to pass it to a selector using mapStateToProps. collection.component.jsx import { useParams } from "react-router-dom"; import { connect } from "react-redux"; import { selectShopCollection } from…
2
votes
2 answers

Difference between createSelector and createDraftSafeSelector API in Redux Toolkit

createSelector mentioned at https://github.com/reduxjs/reselect createSelector API, which generates memoized selector functions. createSelector accepts one or more "input" selectors, which extract values from arguments, and an "output" selector…
Alok
  • 7,734
  • 8
  • 55
  • 100
2
votes
2 answers

What is the proper way to avoid rerenders when selecting an array in React Redux?

Is there a way to select a derived array from an array in a Redux store without spurious renders? My Redux store contains an array of objects. state = {items: [{id: 1, keys...}, {id: 2, keys...}, {id: 3, keys...}, ...]} I wrote a selector to return…
2
votes
2 answers

Is createSelector necessary if there are no calculations?

In a tutorial I follow, they have this piece of code that creates 2 selectors: const selectCart = (state) => state.cart; export const selectCartHidden = createSelector( [selectCart], (cart) => cart.hidden ); ... export const…
Free Me
  • 195
  • 2
  • 10
2
votes
1 answer

React Redux Reselect - Undefined State

I have the following code in my react/redux app: import { createSelector } from 'reselect'; const selectMembers = state => state.membersData; const makeSelectLessonSets = createSelector( selectMembers, substate =>…
asanas
  • 3,782
  • 11
  • 43
  • 72
2
votes
1 answer

Populating a button array with dynamic button text only work if one button

I learn React and JavaScript and now I have this problem Here's a Codesandbox What happens is like this: In the Codesandbox at FileEditor.jsx: I mock it like this: // Mocking the tag list just to test it const tagMock = ['11111']; // THIS WORKS WITH…
Kid
  • 1,869
  • 3
  • 19
  • 48
2
votes
2 answers

I'm confused about the arguments that i passe to a selector function that uses reselect inside containers

I'm learning the usage of reselect, but i'm confused about the way i make use of the memoized selector in inside my container. I've got a component called Summary that received 3 props thats are subtotal, tipAmount , total . It looks like this…
Christian LSANGOLA
  • 2,947
  • 4
  • 22
  • 36
2
votes
1 answer

createSelector of reselect: does it do deep comparison for nested object?

What if second(nested object) changes in redux? If it do shallow comparison it should ignore the change and not re-render. All the example I see in doc, they are based on a simple object, where shallow compare is ok. // assume state is: {data:…
user1360135
  • 57
  • 2
  • 7
2
votes
1 answer

Implementing reselect in redux prevents new changes to appear instantly

In my React project, I have implemented memoization using reselect library. The state basically has a list of objects which I render as cards. Before implementing reselect, whenever I added a new element, the change instantly showed up and a new…
Cyborg7459
  • 157
  • 3
  • 10
2
votes
1 answer

Can we use Reselect memoization with redux for every single selector (even the silmplest getters)?

I am new to Redux and I have been reading quite good stuff around it, including memoization technique (especially with reselect). I have a question though and I struggle to find a proper answer. If we add memoization for every single selector…
OTmn
  • 185
  • 1
  • 2
  • 16
2
votes
1 answer

Getting the following error - TypeError: cartItems.reduce is not a function

I'm trying to count the number of items in an array called cartItems with the reduce function. But it throws off this weird error every time. My selectors code for redux - import { createSelector } from 'reselect'; const selectCart = state =>…
Sam
  • 105
  • 2
  • 11
2
votes
1 answer

Add a selector using reselect in redux

I created an application what filters data according to user input. // ui component import React from 'react'; import { useDispatch, useSelector } from "react-redux"; import { searchPersonAction } from "../store/actions/search"; const Search = ()…
Asking
  • 3,487
  • 11
  • 51
  • 106
2
votes
1 answer

Memoization in react (for example reselect) where thes memoized values are kept?

Memoization in react (for example reselect) where thes memoized values are kept? Some cookie, local storage?
heisenberg7584
  • 563
  • 2
  • 10
  • 30