Questions tagged [redux-reducers]

195 questions
0
votes
0 answers

Typescript Deep Understanding Generic Types with Union Types (Create Reducer example)

I want to set Typescript types for Create Reducer and I want to understand How can I use Generics in this hard construction. Here I have Actions State Object where Keys is name of action type and value is function with 3 parameter (payload, state,…
0
votes
1 answer

How to store and get Cart Items to localstorage with Redux?

I'm using Redux toolkit and adding product items to the cart using redux in my eCommerce app, products are adding to the cart perfectly also I tried to store the added products to the localstorage which is also working fine but the thing is How can…
Mohit
  • 135
  • 10
0
votes
0 answers

Fake authentication state with redux/toolkit updates only on second click

I'm new with react and redux/toolkit, I'm trying to create a fake authentication. The create account function button updates the state on second click, the first click validate the input form only. the following code, is the create account…
maya
  • 25
  • 1
  • 6
0
votes
1 answer

When two createSlice components have reducers with same name then, how to use work with `useDispatch`

Situation: Let's say there are two Slice components defined using redux-toolkit. Because the data category is different, that is why each of them is stored in separate Slice component. Now there are some reducer functions with same name, the inside…
TanmayKr
  • 33
  • 6
0
votes
1 answer

--Uncaught Error: "reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers

1 I am following the Redux tutorials on the Redux site and I am having difficulty using combine reducers. If I run my code without combine reducers, it works fine. As soon as I put the single reducer into the combined reducers function. I get this:…
0
votes
1 answer

React-redux Toolkit: Cannot set new state, when passing reducer as prop to another function

I am trying to use react redux toolkit and pass setter function to set new state on firebase's 'onAuthStateChanged'. The plan was to pass user's state (object or null) to reducer, depending if user is logged in or logged out. This is my first usage…
rey2197
  • 71
  • 8
0
votes
0 answers

Why would I get undefined payload from reducer?

I am trying to get the error message in the reducer so that I can later show it on the front-end. I am getting the error message in the actions. But in reducer I am getting the following value: {type: 'OTP_ERROR', payload: undefined} Actions: …
Ritika
  • 131
  • 1
  • 12
0
votes
1 answer

React Redux: undefined reducer action

I made increment & decrement counter buttons, I'm using redux to trigger actions of increment and decrement but Im getting "Counter.js:11 Uncaught TypeError: Cannot read properties of undefined (reading 'addition')" error by clicking the…
Mohit
  • 135
  • 10
0
votes
2 answers

Reducer in the store is showing an error (react, redux toolkit, typescript)

I am using redux in typescript, i want to make a reducer that will update the state of the store, and my types are: interface IArticle { id: number, title: string, body: string, } type ArticleState = { articles: IArticle[] } type…
Salar Sali
  • 103
  • 1
  • 8
0
votes
2 answers

Create a redux reducer that automatically runs upon calling all other reducers

I have a createSnapshot reducer that will store snapshots of a portion of a slice as the state is being mutated. I have 30+ reducers for the slice. Rather than adding caseReducers.createSnapshot at the end of every reducer, is there a cleaner way to…
Eric P
  • 29
  • 7
0
votes
1 answer

Redux- why are multiple states changing despite dispatching action to only one state

In Redux, I dispatched actions regarding the reducer cakeReducer. But both the state of cakeReducer and IceCreamReducer is being changed, though no action towards IceCreamReducer is not invoked. const redux = require("redux"); const createStore…
0
votes
1 answer

reducers in reduxjs/toolkit and TypeScript

at my first attempt to incorporate Typescript into my redux toolkit , i got an issue defining my reducers in Redux Slice import { createSlice } from "@reduxjs/toolkit"; import { data } from "../data/Reviews"; interface ReviewStateProps { index:…
0
votes
1 answer

How can i correctly use filter and map in the reducers folder for the workouts objects?

I am trying to make the correct delete and update requests for the workout object an I get an error that says the filter is not a function as I am using it on an object and not on an array. Below is the code that I am using for the reducers. import…
0
votes
1 answer

Update a simple boolean with ngrx reducer

i'm learning NGRX and i don't know what i miss for update a state value from a model with the reducer. First i have this model: export interface GlobalModel { navigation: Navigation } export interface Navigation { isNavOpen: boolean, } I have…
orphen92300
  • 105
  • 3
  • 9
0
votes
1 answer

useSelector is not giving the value after useDispatch

I have an api which gives me the result, and I can see the data in my console, but I'm not able to get it in useSelector. import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; import axios from "axios"; import { useNavigate } from…
Venky
  • 1,929
  • 3
  • 21
  • 36