Questions tagged [reducers]

Refers to reducers in the mapreduce framework. Mappers split up a large problem and solve parts of it in parallel. Reducers collect and summarize the output of a map method.

Reference: https://en.wikipedia.org/wiki/MapReduce

791 questions
224
votes
5 answers

Can I dispatch an action in reducer?

is it possible to dispatch an action in a reducer itself? I have a progressbar and an audio element. The goal is to update the progressbar when the time gets updated in the audio element. But I don't know where to place the ontimeupdate…
klanm
  • 2,708
  • 3
  • 17
  • 20
79
votes
7 answers

When should I add Redux to a React app?

I'm currently learning React and I am trying to figure out how to use it with Redux for building a mobile app. I'm kind of confused on how the two are related/usable together. For example, I completed this tutorial in React…
user3802348
  • 1,972
  • 6
  • 27
  • 42
44
votes
2 answers

correct usage of reduce-reducers

I don't understand what reduce-reducers is meant for. Should it be used in the case that I have 2 reducer functions containing the same action? function reducerA(state, action){ switch(action.type): ... case 'SAME_ACTION':…
Amio.io
  • 17,083
  • 11
  • 66
  • 100
37
votes
7 answers

Redux store does not have a valid reducer

Haven't been able to find anything around here regarding this error: "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers." My reducer export default function…
chrysillo
  • 643
  • 2
  • 9
  • 15
32
votes
3 answers

Accessing a part of reducer state from one reducer within another reducer

I do not know how to access a boolean isLoading flag from reducerForm.js reducer in reducerRegister.js. I have used combineReducers() and I use isLoading to disable a button during form submit. It's initial state is false, after clicking submit, it…
Ilija Bradaš
  • 525
  • 2
  • 8
  • 10
30
votes
3 answers

Why does TypeScript infer the 'never' type when reducing an Array with concat?

Code speaks better than language, so: ['a', 'b', 'c'].reduce((accumulator, value) => accumulator.concat(value), []); The code is very silly and returns a copied Array... TS complains on concat's argument: TS2345: Argument of type 'string' is not…
27
votes
1 answer

ReactJS: How to handle Image / File upload with Formik?

I am designing a profile page for my site using ReactJS. Now my question is how do I upload the image from local machine and save it to the database and also displaying it in the profile page import React, {Component} from 'react'; import { connect…
TMA
  • 1,004
  • 1
  • 15
  • 31
23
votes
6 answers

React useReducer: How to combine multiple reducers?

I'm not a Javascript expert so I wondered if anyone has an "elegant" way to combine multiple reducers to create a global state(Like Redux). A function that does not affect performance when a state updating multiple components etc.. Let's say I have…
Freddy.
  • 1,015
  • 1
  • 7
  • 21
22
votes
3 answers

Update single value in item array | react redux

I have a todo list and want to set the state of that item in the array to "complete" if the user clicks on "complete". Here is my action: export function completeTodo(id) { return { type: "COMPLETE_TASK", completed: true, …
Filth
  • 2,723
  • 7
  • 47
  • 71
22
votes
4 answers

Accessing a reducer state from within another reducer

I have a reducer whereby I am retuning the appropriate state when an action is dispatched. Now I am calling an API at regular intervals so the result will trigger an action again and again. So what I want is that if the reducer state already has…
Shubham Khatri
  • 211,155
  • 45
  • 305
  • 318
21
votes
1 answer

Redux: Colocating Selectors with Reducers

In this Redux: Colocating Selectors with Reducers Egghead tutorial, Dan Abramov suggests using selectors that accept the full state tree, rather than slices of state, to encapsulate knowledge of the state away from components. He argues this makes…
pjivers
  • 1,283
  • 12
  • 20
17
votes
2 answers

“Combiner" Class in a mapreduce job

A Combiner runs after the Mapper and before the Reducer,it will receive as input all data emitted by the Mapper instances on a given node. then emits output to the Reducers. And also,If a reduce function is both commutative and associative, then it…
wayen wan
  • 207
  • 1
  • 2
  • 7
13
votes
2 answers

GraphQL - return calculated type dependent on argument

Overview (simplified): In my NodeJS server I've implemented the following GraphQL schema: type Item { name: String, value: Float } type Query { items(names: [String]!): [Item] } The client query then passes an array of names, as an…
Shlomi Schwartz
  • 11,238
  • 25
  • 93
  • 155
13
votes
1 answer

How do you clean up Redux' state?

As a Redux beginner, given (the idea of) a somewhat larger application I imagine a root reducer similar to: const rootReducer = combineReducers({ accounting, crm, sales }) Application state in this case would contain accounting, crm, and sales even…
Thomas Luzat
  • 638
  • 7
  • 18
11
votes
4 answers

Number of reducers in hadoop

I was learning hadoop, I found number of reducers very confusing : 1) Number of reducers is same as number of partitions. 2) Number of reducers is 0.95 or 1.75 multiplied by (no. of nodes) * (no. of maximum containers per node). 3) Number of…
Mohit Jain
  • 327
  • 2
  • 4
  • 16
1
2 3
52 53