Questions tagged [redux-selector]

15 questions
9
votes
1 answer

useSelector and reselect , which one is performance beneficial

For memoization/performance consideration, using useSelector with ShallowEqual. Will there be some more benefits for performance optimization using "Reselect/createSelector" option ? Or both the options are same ? Will have the data as JSON array…
dsi
  • 3,199
  • 12
  • 59
  • 102
2
votes
0 answers

How do I get this Items from my Data using redux-selectors

I have a data inform of an object which has an object also bearing the name of a route name, then inside that object again there is the route name, title and items inside but the items is in array form. Then Using selectors from redux I plug out the…
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
1
vote
0 answers

RTK Query createSelector that uses query cache

I'm trying to selected some data that is deeply nested within the result of the RTK Query api cache. The issue I'm having is that I'm unsure how to define and use the custom createSelector properly so I can pass in the multiple parameters needed to…
Gurnzbot
  • 3,742
  • 7
  • 36
  • 55
1
vote
1 answer

Cannot read properties of undefined (reading 'map') using react-redux slice from an API

I am trying to loop over the items i am receiving in my slice but i am getting the error Cannot read properties of undefined (reading 'map'), i am new to redux i am just trying to learn the pattern here, the connection between the backend and…
1
vote
1 answer

redux calculated data re-rendering how to fix

I have a list of cards that take the state tree. I have one selector that gets the list of jobs, then two selectors that use that selection to map and combine an object to pass into the card. function ProductionJobs(props) { const jobData =…
altruios
  • 986
  • 1
  • 10
  • 29
1
vote
0 answers

Applying several filters using Redux Selectors and Reselect, what is better?

I have three filtering functions In my selectors.js file, which take state and return filtered state, let's say : filter1(state){...}; filter2(state){...}; filter3(state){...}; I need to combine them together so that the state could go through…
Slava.In
  • 597
  • 1
  • 9
  • 22
1
vote
1 answer

Not getting a return from React-redux

I want to filter the results from my store in React-Redux. Therefor I have created a filter selector. My code only returns all the "shoppers", while it should only be returning the filtered shoppers. Each shopper has an array of reviews that…
Ali Lotfi
  • 125
  • 1
  • 1
  • 12
0
votes
1 answer

Read RTK-Query state in a selector without having to pass the cache key

Very simple: Let’s say we use RTK-Query to retrieve the current weather. For that, I pass to the endpoint the arg ‘Paris’ as city. It will serve the current weather of my « game ». Then later, in a Redux selector, I need to compute some derived…
Mik378
  • 21,881
  • 15
  • 82
  • 180
0
votes
0 answers

What is equivalent of useQueryState for a redux toolkit mutation?

You can get data from redux store using the redux toolkit hook useQueryState https://redux-toolkit.js.org/rtk-query/api/created-api/hooks#usequerystate const useQueryStateResult = api.endpoints.getPosts.useQueryState(arg, options) this property…
Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73
0
votes
1 answer

easy-peasy computed does not take inputs

The Redux library easy-peasy has a function called computed which is an alternative to standard Redux selectors: import { computed } from 'easy-peasy' const model = { session: { totalPrice: computed(state => state.price + state.tax) …
Mohammed Ibrahim
  • 418
  • 4
  • 11
0
votes
1 answer

TypeError: Cannot destructure property 'title' of 'collections' as it is undefined

I am trying to get collections using selectors. Here is my code: Selectors import { createSelector } from "reselect"; export const selectShop = state => state.shop; export const selectCollections = createSelector( …
SnehaPk
  • 11
  • 3
0
votes
1 answer

ReactJs a state is triggeing in a loop when I use a selector normal function

Main problem: I tried to use a function inside the selector to reestructur the data and join another variable, in this case my group and put together with their children as items, the problem is that the function is called every time on an infinite…
lumaluis
  • 113
  • 1
  • 2
  • 5
0
votes
0 answers

Selector not up to date in component

I have a simple app using react-native and redux: import { createReducer, createActions } from 'reduxsauce'; import Immutable from 'seamless-immutable'; /* ------------- Types and Action Creators ------------- */ const { Types, Creators } =…
Cereal Killer
  • 3,387
  • 10
  • 48
  • 80
0
votes
2 answers

React Redux - how to derive and then aggregate data in mapStateStateToProps using a selector?

I have a component that returns an object called Progress, inside of which is an array called Results. This array has objects with various properties, one of which is called total { Progress: { count: 100, results: [ {total: 4, ...},…
rmcsharry
  • 5,363
  • 6
  • 65
  • 108