Questions tagged [redux-thunk]

Thunk middleware for Redux. Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch and getState() as parameters.

Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch and getState() as parameters.


Related tags

2622 questions
0
votes
0 answers

redux thunk fetch API

I am working on a React app the app use component level state i want to refector the app and convert to redux thunk but I am stuck at redux initial state how to mangage can someone look at. const [data, setData] = useState([]); const [userData,…
Ahmad
  • 1
0
votes
0 answers

Problem with Nested asynchronous reading with relational data (React, Redux/Toolkit, Python/Django)

I have three tables in the backend, restaurants, categories and dishes, a restaurant can have several categories, and a category can have several dishes I made the endpoints with Python/Django, AND IT’S WORKING OK, I tested them with…
Rafael
  • 2,413
  • 4
  • 32
  • 54
0
votes
1 answer

Problem with Redux Async data pulling from json server

I have a simple react CRUD table application, where I have set up redux to do the add,delete and update function and now I am trying to pull the data from json server with redux. and here is how my slice looks like: import { createSlice,…
Kenertj
  • 57
  • 7
0
votes
0 answers

How would you chain dependin API calls in react redux createAsyncThunk?

I'm working currently on a side project with react and tmdb api, that in one of it's functionalities, shows a random movie to the user. But since tmdb api doesn't have a random call endpoint, I have to achieve it chaining some api calls where the…
0
votes
1 answer

Redux error when submitting a form: Actions must be plain objects. Instead, the actual type was: 'Promise'

I'm trying to submit a form using Redux, however, getting an error message in the console: Uncaught Error: Actions must be plain objects. Instead, the actual type was: 'Promise'. You may need to add middleware to your store setup to handle…
0
votes
0 answers

Unable to display the data into textfield using redux toolkit

I'm trying to update my data but them problem is unable to display the data into Texfield. But in console log or network the data are display. Please see below my code. Please anyone help. Thanks // Update Form const { id } = useParams(); const…
dhaJAY
  • 13
  • 3
0
votes
0 answers

How to redirect after fullfield response?

I want to redirect user after successfully registration. How does it do? This is my request export const signUp = createAsyncThunk( 'users/singUp', async (newUser: INewUser, { rejectWithValue }) => { …
0
votes
0 answers

Redux-toolkit: how to set fetched data to redux slice's state?

Is there a way to set fetched data to Redux state inside of reducer file itself? I want my 'videoList' and 'showVideos' to be equal to fetched data on first render. import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; import axios from…
rey2197
  • 71
  • 8
0
votes
0 answers

TS Error in Redux Toolkit - Argument of type 'object' is not assignable to parameter of type 'WritableDraft'

type UserData = { accessToken: string; id: number; ldap: string; roles: []; tokenType: string; }; type LoginState = { loading: 'idle' | 'pending' | 'succeeded' | 'failed'; data: UserData[]; }; const initialState: LoginState…
Nikhil
  • 101
  • 8
0
votes
0 answers

Problems about appending new state to old state in redux thunk

IMAGE LINK HERE. it doubles the initial return. import { createAsyncThunk, createSlice } from '@reduxjs/toolkit' import axios from 'axios' let url = 'http://localhost:3000/api/v1/posts' const initialState = { allPosts: [], isLoading:…
0
votes
1 answer

send multiple RTK query request in response of another RTK Query

I am new to RTK Query and when I fetch some data from an endpoint I get a response of an array of objects for each id of item in the list I have to call another API to get the details of each item. but I do not know have to achieve this. for…
Amir Rezvani
  • 1,262
  • 11
  • 34
0
votes
2 answers

How to return an object in Redux?

I have a button that, when clicked, sends an object [ Dispatch(ADDS(myObject) ], but my [ Reducer ] does not return the object as the first ( index 0 ), it returns the first item ( empty ) because the ( InitialState ) it is set to ( empty ). How do…
user17016241
0
votes
0 answers

Why getting empty array after fetching data successfully in redux react?

Hello am currently using redux toolkit in my project & i have encountered a problem when i was fetching data from back-end.The action type is success, the data is stored in the action's payload successfully and it keeps returning an empty array…
najlae01
  • 1
  • 2
0
votes
1 answer

Is it okay to pass dispatch and getState from a Redux thunk function down into helper functions?

Let's say I have a thunk which is a top-level function: export default () => (dispatch, getState) => { // do stuff here childFunction(getState) // is it okay to pass in getState so that children down the chain can call getState? …
noblerare
  • 10,277
  • 23
  • 78
  • 140
0
votes
0 answers

How can we make the global redux state in micro frontend as read only

I am using micro frontend and I am trying to change the architecture of state. Instead of using single state and a combined reducer I am using individual state for individual micro frontend apps. And also I am using a global state for cross…