Questions tagged [redux-actions]
101 questions
16
votes
7 answers
What is a difference between action,reducer and store in redux?
I am new to react/redux. I am trying to figure out how all the pieces in redux interact. The one thing giving me trouble is understanding the relation between actions and reducers,store.

Dishant Chanchad
- 710
- 3
- 9
- 27
5
votes
2 answers
Returning a dispatch with promises in action creators of react redux
I have an actionCreators in my /actions/authenticate.jsto seperate the logic of the actions dispatched by redux and the component of react.
Here is my authenticate.js which is my actionCreators
export function login(email, password) { // Fake…

KnowledgeSeeker
- 1,058
- 2
- 19
- 44
5
votes
1 answer
Redux + Normalizr : Adding and deleting normalized entities in Redux state
I have an API response which has a lot of nested entities. I use normalizr to keep the redux state as flat as possible. For eg. the api response looks like below:
{
"id": 1,
"docs": [
{
"id": 1,
"name": "IMG_0289.JPG"
},
…

Gaurav Kumar
- 1,091
- 13
- 31
3
votes
1 answer
How to type 'prepare' function in redux-toolkit
I am using redux-toolkit prepare function to construct the final payload value.
addTodo: {
reducer: (state, action) => {
state.push(action.payload);
},
// ERROR: **Type '{ payload: Todo; }' is missing the following…

Rashomon
- 5,962
- 4
- 29
- 67
3
votes
0 answers
A computed property name must be of type 'string', 'number', 'symbol', or 'any'.ts
I am using redux-saga and redux-actions with Typescript, like this:
const moviesReducer = handleActions(
{
[actions.fetchMovies]: (state) => ({
...state,
details: {...initialState.details},
}),
…

RowanX
- 1,272
- 2
- 14
- 27
3
votes
2 answers
TypeScript return type of Redux action
I have this in a codebase;
export const login = (user, pass) => {
return (dispatch) => dispatch({ type: LOGIN });
}
what is the return type of login?
I tried this:
export const login = (user, pass) : ReducerAction {
return (dispatch) => …
user12849275
3
votes
2 answers
How to use combineReducers with handleActions
I'm trying to create new reducer survey, which must combine name and questions reducers while using handleActions from redux-actions package. But I recieve an error Invariant Violation: Expected handlers to be a plain object. How should I change it…

TyraelS
- 33
- 4
3
votes
2 answers
Why are React Actions dispatched using a Return function
While reading through a React/Redux boilerplate, I came across the following code snippet
/components/auth/signout.js
import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as actions from '../../actions'
class…

Nyxynyx
- 61,411
- 155
- 482
- 830
3
votes
1 answer
Confused about Redux createAction and dispatch
I want to build a function in React + Redux that, when a user clicks a button, calls an API and loads the data into the store, then display the data on a page.
I want to use the redux-actions framework: https://redux-actions.js.org/ but I'm a little…

user4184113
- 976
- 2
- 11
- 29
3
votes
2 answers
Using redux-actions, redux-thunk and redux-promise-middleware in typescript
New to typescript + redux ecosystem here.
How do I properly encapsulate type information into async actions when using redux-actions, redux-thunk and redux-promise-middleware in TypeScript?
An example of authentication:
/* actions */
const login =…

Srishan Supertramp
- 395
- 1
- 9
2
votes
1 answer
Redux thunk - Error · Actions must be plain objects. Use custom middleware for async actions even with dispatch an object with key type
Getting below error for specific action functions:
Error · Actions must be plain objects. Use custom middleware for async
actions
Below code works fine on my system but loging erros on bugsnag for different users.
React component file:
import…

Always_a_learner
- 4,585
- 13
- 63
- 112
2
votes
1 answer
What is the main benefit of using action creators in Redux?
Let's say I have an input component that will update the state from its onChange handler.
function updateInputState(newvalue) {
return({
type: "UPDATE_INPUT_STATE",
payload: newValue
});
}
function InputComponent(props) {
function…

cbdeveloper
- 27,898
- 37
- 155
- 336
2
votes
1 answer
Is it possible to return an object with more than 2 fields to an action in Redux?
I am a newbie on react redux , can I create a Action with more than 2 field?
normali an action return a object with
{type : same_vale, paylod : same_vale}
Is it possible to return from a action something like this:
{type : same_vale , paylod :…

Angelotti
- 673
- 1
- 6
- 20
2
votes
1 answer
React Redux Unexpected token, expected ","
I am using React with react-redux and redux-actions.
I have the following reducer that keeps telling me
unexpected token, expected ","
but I am not sure why.
comments.js (reducer):
import { handleActions } from "redux-actions";
import {
…

CHBresser
- 185
- 2
- 2
- 15
2
votes
1 answer
What does this array-style destructuring on a function do in ES6?
I read through the redux-actions tutorial, and am confused by their use of (what I believe to be) destructuring. Below is an example (increment & decrement are both functions returned by the createAction function).
const { createAction,…

thisissami
- 15,445
- 16
- 47
- 74