Questions tagged [redux-reducers]

195 questions
1
vote
2 answers

How to display username on navbar after login in react redux

There is a nav link on my navbar named Login (I have used bootstrap navbar). After successful login I want to replace Login with a username using react-redux (not redux-toolkit). Kindly help me in writing reducer and action code. As I am a beginner…
1
vote
1 answer

Uncaught Invariant Violation on saving to redux store second time

I'm relatively new to React-Redux and was facing an issue where the if i update the state of a reducer param for the first time, it executes perfectly, then if i execute it again with some different value it throws this exception in my try/catch…
Sampurna
  • 205
  • 2
  • 9
1
vote
1 answer

reducer A make reducer B undefined (React - Redux)

I have two reducers inside a combine reducer, and when I call an action to change the state of reducerSrc, my state of reducerTherm get undefined and I receive an error. How can I fix this? combine: const rootReducer = combineReducers({ …
Marin
  • 141
  • 4
  • 13
1
vote
2 answers

Redux state changes but not reflected in component

I'm trying to implement a shopping cart using redux. here is my cart-reducer: export const cartReducer = ( state = { cartItems: JSON.parse(localStorage.getItem("cartItems") || "[]")}, action) => { switch (action.type) { case ADD_TO_CART: return {…
1
vote
1 answer

getting a 'No reducer provided for key "auth"' error using configurestore in redux-toolkit

Getting the 'No reducer provided for key "auth"' error, think it's to do with how I'm passing it to the store from the slice. Everything is working fine apart from the No reducer error. Should I use a rootReducer ? Looked through the documentation…
Ricksta
  • 27
  • 1
  • 4
1
vote
1 answer

slice reducer for key "pageName" returned undefined during initialization

I am creating redux app using createSlice(), but get the error: Error: The slice reducer for key "pageName" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The…
EzyHoo
  • 301
  • 2
  • 14
1
vote
1 answer

TypeError: bookmarks.map is not a function

I am working on a React application and I am using Redux to manage the state. I have the following code: reducer.js import { actionTypes } from "./actionsTypes"; const initialState = { items: [], loading: false, error: null, bookmarks: [], …
Rayen Mehrez
  • 105
  • 1
  • 12
1
vote
3 answers

How to do muliple assign and add operations in reducer function in redux react.js?

I am working on a react app where I am using redux for state management,I am new to this and I have to do multiple state change operations inside a reducer function. Here's my reducer function: case Actions.ON_SUBMIT_CLIENT: { return { …
rudeTool
  • 526
  • 1
  • 11
  • 25
1
vote
2 answers

TypeError: Cannot destructure property 'error' of 'panelMembersList' as it is undefined

I am trying to load data from Django REST API server using redux and axios, similar approach I used in my other screens like Products, BlogPosts, they are working fine, Now I need to load another model from api but I am not sure why is this error…
Faisal Nazik
  • 2,367
  • 4
  • 17
  • 40
1
vote
1 answer

Component don't re-render after redux modification

I'm using redux in my app and at first, it works as I want. When I add something into my state through the reducer, my component is re-rendering as I want. But when I only modify the value of a property inside the state, my component isn't…
1
vote
1 answer

Can I get the index of an object am currently at when setting state in react redux?

Am working on a todo app using react redux, its initial state is an object initialState and has an array task which is an empty array. When setting the values of the task, I can't seem to find a way to get the current index of the objects to assign…
1
vote
2 answers

why my reducer is slow to storage the result?

EDIT: i have adjusted my code a bit, and now i am pretty sure that my reducer returns undefined at the 'action' no matter what comes in. So I think it is the thunk that is the problem, or the combinereducer. Additionally i have return fixed…
Om Alba
  • 44
  • 7
1
vote
0 answers

I can not use the data from redux store inside my useState hook to showcase the images

enter image description here Here the singleCard object has all the details about the product such as id, title, src etc. I can console log the singleCard as console.log(singleCard) which shows all the data passed from redux store , but I can't get…
1
vote
1 answer

Error: [Immer] An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft. (Boardgame.io)

i know there is a quite similar question here in stackoverflow but i cant figure out what is the error in my code. To sum up, im pretty new to React and Javascript (i also know nothing about redux) and I am doing a project in Boardgame.io. This…
Ic3Style
  • 21
  • 3
1
vote
1 answer

Update screen with reducer in react native

im trying to add a picture in the task, and after this, update the flatlist to see the update but it does not with. It works if I close and return on the app. If I display the store, I also see an instant update but not in my screen. Here is a part…
user123456
  • 171
  • 11