Questions tagged [redux-reducers]

195 questions
1
vote
1 answer

React redux - pushed object in the state is not mapped but initialState is

I am working on some app where you can save a note about a video. I have some redux issues, sorry that I am not specific but I don't know where the problem is. Every time when I am using 'ADD_ITEM' action, everything works fine in the devtools I can…
1
vote
1 answer

(React Redux) The whole state restarts and deletes all changes made when I add a new item

The reducer goes like this: import { CREATE_COUNTRY, } from "../actions/actionConsts" export const storeInitialState = { countries: [], otherThings: 0 } export default function countriesReducer(prevState = storeInitialState, action)…
Rafael
  • 2,413
  • 4
  • 32
  • 54
1
vote
1 answer

How do I fix my reducer to return the property value of an object?

I have a reducer in my react native app which ideally should check the state and return if the recipe has been favourited or not. I've tried to create a reducer to return if isFav is true or false for a recipe object in the state. If the recipe is…
Ashley Vaz
  • 55
  • 8
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
  • 77
  • 1
  • 11
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 =…
Niko Bellic
  • 59
  • 2
  • 9
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
  • 507
  • 10
  • 21
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
  • 463
  • 5
  • 13
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…
WillMaddicott
  • 512
  • 6
  • 20
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

One big action or two small ones on Redux Reducer

I'm using redux for my react-native project. I have to use some Switch components(true or false) to select differents colors and save them into an array in the state. I can have an empty array or for example ["black","white"] according with my…
1
vote
1 answer

React : retrieve info async with useReducer and useContext

I am trying to reproduce something I was doing with Reactjs/ Redux/ redux-thunk: Show a spinner (during loading time) Retrieve information from remote server display information and remove spinner The approach was to use useReducer and useContext…
johann
  • 1,115
  • 8
  • 34
  • 60
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
  • 463
  • 12
  • 35
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
  • 580
  • 4
  • 14
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
  • 197
  • 2
  • 13