Questions tagged [redux-reducers]

96 questions
0
votes
0 answers

Redux state - only sometimes it shows "states are equal"

I am using ReactJS together with Redux and have a problem with a redux update. In a component I have the following: import { connect } from "react-redux"; import { Dispatch } from "redux"; import { State } from "state/State"; import { FormActions…
Gutelaunetyp
  • 1,446
  • 2
  • 7
  • 27
0
votes
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…
0
votes
1 answer

When I register I cannot see the user name until I refresh or login

when I register it take me to the dashboard page where there is a welcome note with user name but the issue is I cannot see the user name until I refresh or login again. I am sharing both my registration action.js code and my dashboard my…
jzee
  • 37
  • 7
0
votes
1 answer

Attempted import error: 'addToCart' is not exported from '../actions/cartActions'. with Redux

I am following a tutorial to learn Redux and use this in my own project. Every action i used before work perfectly. But for my last action i get this error: Attempted import error: 'addToCart' is not exported from '../actions/cartActions'. Here the…
ruldane
  • 11
  • 3
0
votes
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…
0
votes
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
  • 39
  • 4
0
votes
1 answer

How to listen for global action and update the rootState directly, while using multiple slices with Redux Toolkit?

I've got a state in my Redux store shaped like this: type RootState = { PAGE_A: StatePageA, PAGE_B: StatePageB, PAGE_C: StatePageC, // AND SO ON... } Each page is a slice created with createSlice from @reduxjs/toolkit I'm using Next.js static…
cbdeveloper
  • 14,014
  • 11
  • 57
  • 145
0
votes
1 answer

state undefined in file tree reducer

I want to just return an array of objects from my reducer, but useSelect() returns undefined reducer/directories/index.js: export * from './reportDir' reducer/directories/reportDir.js: const reportDir = [ { type: 'cat', name: 'گزارش ها', …
John
  • 39
  • 4
0
votes
1 answer

Redux: Call thunk action from slice reducer action

I have a tree structure which is loading children on demand, this is my reducer. The problem I have is that when I want to call my thunk action from toggleExpandedProp I get exception (see bellow). What should I do? import { createSlice,…
Teamol
  • 409
  • 1
  • 9
  • 31
0
votes
2 answers

TypeError: can't access property Symbol.iterator, state[action.payload.savedVideos] is undefined

I have a problem with redux. I am working on an app where you can save a note about your youtube video. Everything is working fine, but when I started adding the 'ADD_ITEM' action I have the same mistake every time with this action in my reducer.…
0
votes
1 answer

Using immer can not modify property Number of nested object

I am using Angular 2+ with Redux and is fine, but can not modify quantity with the new value The error is: TypeError: Cannot assign to read only property 'quantity' of object '[object Object]' export interface CartState { readonly cars:…
0
votes
1 answer

what happens after dispatch function and reducer function in react-redux?

suppose if i dispatch an action using dispatch() , i know that reducer() is called which has an action object and current state as parameters . i want to know what calls that reducer function ? which functions are called before reducer function and…
0
votes
1 answer

unable to understand reducer function in react redux

this is my reducer function : export default (posts = [], action) => { switch (action.type) { case FETCH_ALL: return action.payload; case LIKE: return posts.map((post) => (post._id === action.payload._id ? action.payload :…
0
votes
1 answer

TypeScript & React: reusable generic actions / components

I use TypeScript with React and useReducer and I want to define reducer Actions in a type-safe way. The simplest approximation of Action is: type Action = {name : string, payload : any} The more precise version requires union types: type Action = …
Ivan Kleshnin
  • 1,242
  • 2
  • 12
  • 19
0
votes
1 answer

Redux spread InitialState pattern

Recently I stumbled upon the codebase where every reducer looks like the following. I guess they are spreading initialState to get rid of some 'leftover' nested state when reducer initialises, but is it meaningful? const initialState = {...} const…
firedev
  • 19,222
  • 18
  • 58
  • 91