Questions tagged [redux-reducers]

96 questions
1
vote
1 answer

Get the state variable after dispatch is finished in react redux and saga?

Hello I am fairly new to React, Redux and Saga. So I have a scenario where I have a .jsx file which is the view file then an action file used for dispatch and I am also using saga which updates the data in the reducers. Following are the file…
Akshay
  • 71
  • 10
1
vote
1 answer

ReactJS & Redux - TypeError: state.reduxCart is not iterable

I am trying to insert items in redux but when i click the button I get the following error : TypeError: state.reduxCart is not iterable My Reducer code : const INITIAL_STATE = { reduxCart: [], reduxCartCounter: 0 } export default (state =…
1
vote
2 answers

how to update state with reducer, when my state is an array not an object

I have a problem with returning new state in my reducer function. My state is an array of objects. Each object has two key value pairs category: '' and items: [{}, {}, {}]. const initialState = [ { category: 'vegetables', items: [ { …
1
vote
1 answer

Redux: altering different parts of the initial state in Reducer according to Actions

I have the following Reducer: const initialState = {} const dishReducer = (state = initialState, action) => { switch (action.type) { case 'LOAD_DISHES': return (action.dishes) case 'LOAD_DISHES_ERROR': …
Ghadir
  • 171
  • 2
  • 10
1
vote
0 answers

Trigger refresh of related components

I have a React-Redux app which displays a dashboard page when the user first logs on. The dashboard displays a number of statistics/graphs etc. which are components most (not all) of which are filtered based on a state site value. This site value is…
Leigh.D
  • 53
  • 8
1
vote
1 answer

Simple React Redux state returns undefined

I am completely stumped on this one. I've built the simplest of simple react redux component that currently only shows a counter held in the store. However this counter is always returned as undefined! I'd expect the counter to return 0 as this is…
dtwoo
  • 301
  • 3
  • 12
1
vote
1 answer

Delete one item in an array ReactJS (React Hooks and Redux)

I'm creating a recipe application using MERN stack. The issue I am stuck on is trying to delete an ingredient found in an array, inside a recipe object. My recipe object looks like this: MongoDB Recipe Object Each ingredient has a cross next to it…
Saskia
  • 11
  • 1
1
vote
1 answer

Which reducer gets used when using dispatch in mapDispatchToProps?

I am learning about Redux and I have two reducers, a contactReducer to show contacts on the page and a testReducer to just mess around with. In one of my component files I have this function: const mapDispatchToProps = (dispatch) => ({ …
mastercool
  • 290
  • 2
  • 17
1
vote
0 answers

Where to put converting PDF function?

I have the following scenario: send API request with contract id as a payload when clicking download contract button get the pdfBuffer field in API response have a fuction A which can convert pdfButtfer to pdf file in index.js under Actions export…
Yang Wang
  • 388
  • 2
  • 9
1
vote
2 answers

(import from default export) Is the root reducer in Redux automatically called 'rootReducer'?

I'm going through many Redux-tutorials, and something that confuses me, is the fact, that when creating a Redux store with a combined reducer, there often is the reference to a name rootReducer as the root reducer, although it has never been…
Schelmuffsky
  • 118
  • 8
1
vote
1 answer

parameter for reducer will not update at dispatch

I think my code is correct, it goes to check QueryString is undefined. If yes, then 'thePath' get the value from a config file. If QueryString has a value(which means not undefined anymore) then let the value of 'thePath' be QueryString. And it…
adnan tariq
  • 127
  • 10
1
vote
1 answer

Can I have one TypeScript Reducer with JavaScript Reducers in my combineReducers?

export default combineReducers({ todosReducer, calculatorReducer, dateReducer, }); I am trying to integrate TypeScript into part of my large codebase. In the example above imagine the first two reducers are JavaScript and the last is TypeScript.…
fullStackRyan
  • 305
  • 1
  • 2
  • 8
1
vote
1 answer

Must a reducer in Redux strictly return a new state object?

One rule of reducer in Redux is: we should treat state as read-only, and return a new object as the new state. But there is one grey area: must it strictly return a new object as state, or can we return the same state object? It seems by looking at…
nonopolarity
  • 130,775
  • 117
  • 415
  • 675
0
votes
0 answers

Using {...state} instead of state in persistReducer in redux

So i was using redux-persist in my react-native app to persist the state and everything is working fine. For the reducer, i was using switch-case to check for different action-types and for the default i was returning the state. initialState =…
Irfan wani
  • 1,474
  • 2
  • 6
  • 17
0
votes
1 answer

How to pass array objects or store them in reducer using interface and how does filter works on it?

I had a problem when storing an object array in state using reducers. I had this code this below: This is my interface: interface fontStyle { fontSize: number; fontData: FontFamily[]; } interface FontFamily { family: string; } This…
William
  • 65
  • 6