Questions tagged [redux-reducers]

96 questions
0
votes
0 answers

How to display date based on different date formats from redux reducer in react?

I'm passing the reducer to all pages which carries the required info. Now, based on the dateformat selection from a dropdown, it is passed to all the pages. I want to bind that selected item to the bubble chart in x-axis, where the chart is…
0
votes
0 answers

How Can I filter an array of objects from reducer inicialstate in another component?

Well, I create a project with react and redux. In the reducer inicialstate I have an array of objects. I distribute the items on screen using map, ok. But my main doubt is that I create a filter compoment with an input, but I dont know how can I…
Caroline
  • 21
  • 3
0
votes
1 answer

Unable to logout a user without putting a 'case LOGOUT' in all reducers

I am new to redux and trying to create a small site in which users can: login, register and logout. I have created 2 reducers for login and registration and I have a "isLoggedIn" field initialized in both reducers' state. When trying to create a…
Wicked528
  • 1
  • 1
  • 1
0
votes
2 answers

trying to remove all items and add incoming items from a nested redux object

I have below reducer and below initial State. classinfo is the parent state which has a nested state array of students. with the below reducer I am planning (replace previous students with new students ) to delete all students from the previous…
dev0864
  • 175
  • 1
  • 11
0
votes
1 answer

Calling a redux action inside another action is not working

i have console log the error and the error is visible in console but the setAlert action is not dispatching , why is that ? This is the Auth action code import axios from "axios" import {setAlert} from "../actions/alert"; import { REGISTER_FAIL }…
0
votes
1 answer

Redux adding an object to an array not working for the first record only

When adding an object to an array with Redux, for some reason adding the first record would not work. I would get the following error: TypeError: Invalid attempt to spread non-iterable instance. in order to be iterable, non-array objects must have a…
hugger
  • 263
  • 2
  • 11
0
votes
1 answer

Will using selectors to compute derived data from an API call perform better than doing within the reducer? (for this use-case)

Say I have a music store app where the user searches for guitars. On initial page load, I fetch a few varieties of guitars to display: (acoustic, electric, and bass). Pages of guitar results are returned together from a single API call but will…
Anthony O
  • 518
  • 3
  • 12
0
votes
1 answer

Should all redux actions have a corresponding reducer?

I think Redux is pretty useful for debugging because it tracking what actions were dispatched by your app in its dev tools. Is it bad practice to dispatch an action with no intention of handling it with a reducer? For example, I want to make an…
alanrzhang
  • 29
  • 4
0
votes
1 answer

Why state variable inside redux Reducer not not increment by 1

I have a simple two button on the web page one for increment and one for decrements an integer. Once i click on + button it will add 1 to the current value. Below is my Reducer and i have wrapped "INCREMENT" with a setTimeout and when i click on +…
Kalhan.Toress
  • 20,702
  • 5
  • 63
  • 84
0
votes
3 answers

In a Redux reducer, if state is not defined, can you immediately return the initial state?

I have seen 3 forms of reducers: // Form 1 function reducer(state, action) { if (state === undefined) return state = []; // handle action.type // ... } // Form 2 function reducer(state, action) { if (state === undefined) state =…
nonopolarity
  • 130,775
  • 117
  • 415
  • 675
0
votes
1 answer

What exactly does it mean when we say we cannot mutate the state object in Redux reducer?

Does it exactly mean treating it as "read-only"? For example, if the state is: { arr: arrData, obj: objData, aMap: mapData, aSet: setData } For any of the four that has no change to it, we can keep it as is, but let's say 3 level down obj,…
nonopolarity
  • 130,775
  • 117
  • 415
  • 675
0
votes
0 answers

Redux React state not getting set after data received from reducer

i do have a component in which state={ mediaJson=[] } and i have a reducer which calls an API and returns data and i used static getDerivedStateFromProps(props, state) { return{ mediaJson:props.data } i am getting the data and ist getting…
midhun k
  • 400
  • 4
  • 19
0
votes
2 answers

React Redux -possible to have a call back in dispatch function

Guys i am having some trouble or quite doubtful. am having one component and one reducer. Reducer.js import { ASSET_POPUP_GET_ENDPOINT, } from 'apiCollection'; import { performGet } from 'services/rest-service/rest-service'; export const…
midhun k
  • 400
  • 4
  • 19
0
votes
1 answer

Problem with Reducer that contains few different values

I'm kind of new to React.js & Redux, so I have encountered a problem with Reducers. I am creating a site that have a main "Articles" page, "Question & Answers" page, I created for each one a separate Reducer that both work just fine. The problem is…
0
votes
1 answer

Type { error } is missing in Type , but is required in type - Redux Specific Problem

I have a small problem, typing my Redux Reducer. I know this question, has been generally answered, but I find the solutions lacking, and I would call them more workarounds than anything else. The Problem: I have a Redux Reducer. Inside it, 3…
Dimitris Efst
  • 1,690
  • 2
  • 23
  • 49