Questions tagged [redux-reducers]
195 questions
0
votes
1 answer
Why does my reducer does not display its value in a component?
I have a React.js app where I use Redux. I have an action which is supposed to set a value in the reducer's state but it seems like it does not work. I used console.log() to display the action.payload of the action in the reducer and it seems to be…

Fiphe
- 320
- 3
- 18
0
votes
0 answers
Do I update the state by use of concatenation or do I fetch the updated state from my DB and set my state to that? What is correct?
I'm not sure what the best practice is for updating the state inside of a reducer.
Let's say my reducer is a list of blogs. I've created an action, getBlogs, that fetches these blogs on component mount and I created an action, addBlog, that will add…

Richard V
- 31
- 1
- 4
0
votes
1 answer
React and redux toolkit: how to add reducer that gets data from a drag and drop event
Very new to React and redux. I'm trying to add a file drag and drop feature to my React app but struggling with how that works using redux
toolkit's createSlice function.
I keep getting 'TypeError: Cannot read property 'fileList' of undefined'. I…

goodaytar
- 75
- 5
0
votes
1 answer
Update points Redux React Native
I'm trying to load points from Firebase in order to display it on the screen
I'm using Redux, because the points number can be updated but I can not put this.props.Points.updatePoint inside Firebase request
How can I update it?
Home.js :
class Home…

user123456
- 171
- 11
0
votes
1 answer
How to pass array objects or store them in reducer using interface and how does filter works on it?
I had a problem when storing an object array in state using reducers. I had this code this below:
This is my interface:
interface fontStyle {
fontSize: number;
fontData: FontFamily[];
}
interface FontFamily {
family: string;
}
This…

William
- 89
- 1
- 14
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
- 35
- 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
- 23
- 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
- 27,898
- 37
- 155
- 336
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
- 93
- 6
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.…

TeodorWolski
- 31
- 3
- 6
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…

Tips and Tricks Of Chess
- 55
- 1
- 9
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 :…

Tips and Tricks Of Chess
- 55
- 1
- 9
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,667
- 2
- 21
- 24
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
- 20,898
- 20
- 64
- 94