Questions tagged [redux-reducers]
195 questions
1
vote
1 answer
Multiple extraReducers
i have several extraReducers, that do the same action. I wonder if i did it right:
const favouriteSlice = createSlice({
name: "favourite",
initialState: {
loading: true,
entities: "initial",
error: null,
},
…

Rorrek7655
- 13
- 3
1
vote
1 answer
Why actions in createSlice RTK doesn't work?
I'm creating the todo-app with Redux Toolkit. In this app I have three slice-components which has almost the same logic. All initial states of these components are reachable, but not the actions and reducers. And states in Redux DevTools are…

alienaline
- 13
- 2
1
vote
1 answer
Unable to Delete Contact with Redux Toolkit
I've been doing my latest code with redux tool kit . I've created a simple contact form that fetches data from the rest api(Via JSON placeholder). And also allows a user to add a contact and also edit a contact. However, when it comes to deleting a…

classic88design
- 29
- 3
1
vote
0 answers
Best way to share state between slices in redux toolkit?
If I have a slice like this
cartSlice.js
import { createSlice } from "@reduxjs/toolkit";
import cartItems from "../cartItems";
const initialState = {
cartItems: cartItems,
amount: 1,
total: 0,
isLoading: true,
};
export const cartSlice =…

Eric Andre
- 204
- 2
- 9
1
vote
0 answers
Expected the root reducer to be a function. Instead, received: ''
I receive an error when following a YouTube crash course on redux:
redux.js:158 Uncaught Error: Expected the root reducer to be a function. Instead, received: ''
at createStore (redux.js:158:1) | at redux.js:682:1 | at createStore…

ronzenith
- 341
- 3
- 11
1
vote
1 answer
NGRX state update
this is my State:-
roles =[ {
roleId:"8e8be141-130d-4e5c-82d2-0a642d4b73e1"
name:"HR"
description:"HR of the Company"
isModerator:"N"
},
{
roleId:"8e8be141-130d-4e5c-82d2-0a642d4b73e1"
name:"MR"
description:"MR of the…

Benezir
- 113
- 1
- 9
1
vote
1 answer
Redux toolkit not updating array of array object
I'm trying to update an object that is nested in an array of arrays.
state = [[{away: "Southampton "
awayTeamScore: null
date: "Sat, October 30th 2021"
dateNative: "2021-10-30T14:00:00Z"
home: "Watford "
homeTeamScore: null
matchId: 327264
matchday:…

artworkjpm
- 1,255
- 2
- 19
- 40
1
vote
1 answer
Redux Toolkit caseReducers skip prepare callback in reducer function
I have a reducer for adding comment as follow
addComment: {
reducer: (state,action)=>{
const { newId, comment } = action.payload
console.log(newId)
// functions that create an new comment entry with the newID and update state
},
…

Eric P
- 29
- 7
1
vote
1 answer
State from redux store gets lost/ reset when changing route
I have a simple app that so far only has a main login component, and a home page with a navbar which the user is supposed to be routed to once they login to the app. The user experience should be as follows: user selects name from blue dropdown…

mattangel
- 71
- 4
1
vote
1 answer
Typescript error ts(2322) in reducer return
I want to sort my state and delete exact name, i do it with map&filter, they should return the same state, but with a few changes. But TypeScript threw an error 2322
I use TS+Redux Toolkit
This is the reducer
removeName(state, action:…

rewolc
- 11
- 2
1
vote
1 answer
How to access stores when configureStore has multiple reduces?
import { configureStore } from "@reduxjs/toolkit";
import userReducer from "./userSlice";
export default configureStore({
reducer: {
user: userReducer,
},
});
import React from "react";
import ReactDOM from "react-dom";
import App from…

Bear Bile Farming is Torture
- 4,317
- 4
- 27
- 61
1
vote
2 answers
Configure reducers of connected-react-router and Redux Toolkit Query properly
I am trying to setup reducers of both connected-react-router and RTK Query.
(The old code base has connected-react-router already)
Then I received this error.
fail to setup connectRouter
Type 'Reducer, AnyAction>' is not…

Hung P.T.
- 101
- 8
1
vote
1 answer
Redux Saga authentication with router 6
I am porting an application from Router v2 to Router v6.
I am attempting to get authentication to work.
This bit of code gets hit when the user hits login
sendLoginRequest(event) {
// Prevent the page from unloading from the form…

Mason Fraser
- 61
- 9
1
vote
0 answers
Parent UI is not refresh by reducer update from child in react
I have parent and child component. And I try to update the state from child component. At the parent, UI is not refresh.
Parent.tsx
const formValues = useSelector((state: MYReducer) => state.VTReducer.formValues);
{!formValues.isRetrieveUser &&…

Loran
- 772
- 4
- 16
- 38
1
vote
1 answer
ExtraReducers don't see and change state in authSlice and notifySlice. I use thunk called 'login' to login and call notify actions. What can I do?
My notifySlice
State have to be changed here but it doesn't. ExtraReducers don't see and change state in authSlice and notifySlice. I use thunk called 'login' to login and call notify actions. I also tried to use builder and return instead of 'state…

Bruce Wayne
- 21
- 3