Questions tagged [redux-toolkit]

Redux Toolkit (RTK) is the standard approach for writing Redux logic. It provides utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once.

Redux Toolkit (RTK) is the standard approach for writing Redux logic. It provides utilities to simplify several common Redux use cases, including store setup, defining reducers, immutable update logic, and even creating entire "slices" of state at once.

Redux Toolkit was originally created to help address three common concerns about Redux:

  • "Configuring a Redux store is too complicated"
  • "I have to add a lot of packages to get Redux to do anything useful"
  • "Redux requires too much boilerplate code"

It provides tools that abstract over the setup process for Redux and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.

RTK is beneficial to all Redux users. Whether you're a brand-new Redux user setting up your first project, or an experienced user who wants to simplify an existing application, Redux Toolkit can help you make your Redux code better.

3505 questions
1
vote
0 answers

how to use redux toolkit with firestore in react native

I am using redux toolkit and firebase firestore for backend. I just want to get an array of objects from the database. Below is the code for slice. When I log the payload in the console I am unable to get the data. Thanks in advance. import {…
1
vote
4 answers

Cannot read property 'providesTags' of undefined

I'm using RTK query to get one record via api via "useGetUserQuery" Api Call is ok because backend have result. I use sequelize and my result send data object. I tried to erase providestags but i have the same issue. My front-end return this error…
Nicolas Popy
  • 51
  • 1
  • 7
1
vote
0 answers

Dispatch redux toolkit async thunk by name/type

need your help here. I'm trying to use redux-toolkit with redux-offline. My issue is that I need to find a solution to call asyncthunk from redux-offline's "effect". Ideally it should be : dispatch({ type: 'someOfflineAction', meta: { offline:…
holyris
  • 171
  • 11
1
vote
0 answers

How do you update a state with a time interval using redux toolkits?

I have the following initial state and slice objects. How do I add values to the hand array every second using dispatch? My intention is to have each dispatch be completed before the next one. I looked at createAsyncThunk but I wasn't clear on how…
Dag
  • 33
  • 4
1
vote
1 answer

How to make async calls in prepare method of createSlice of redux-toolkit?

I have the following createSlice method. I looked into the documentation of createSlice where they have given an option to use the prepare method to customize the action creation. I'm trying to make an API call, However the reducer is triggered…
Mahesh Kumaran
  • 887
  • 2
  • 12
  • 30
1
vote
2 answers

Redux with getStaticProps

I'm struggling to understand how I can get around this issue? I want to get data that I can share globally using redux**(using redux as I'm using it for other use cases in my app)**. my problem is I'm using getStaticProps to try and dispatch my…
NoobAndroid
  • 86
  • 4
  • 10
1
vote
2 answers

Redux Toolkit slice with TypeScript expected 0 arguments, but got 1

I have slice const investment = createSlice({ name: 'investments', initialState, reducers: { getInvestmentsRequest(state) { state.investments.status = RequestStatuses.loading; }, } }) And action is intercepted by middleware.…
1
vote
2 answers

react native redux toolkit devtools

how can I add redux devtools with redux toolkit ? import { configureStore, getDefaultMiddleware, compose } from '@reduxjs/toolkit'; import reducers from './reducers'; import createSagaMiddleware from 'redux-saga'; import saga from './saga'; const…
locklock123
  • 197
  • 1
  • 13
1
vote
1 answer

slice reducer for key "pageName" returned undefined during initialization

I am creating redux app using createSlice(), but get the error: Error: The slice reducer for key "pageName" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The…
EzyHoo
  • 301
  • 2
  • 14
1
vote
1 answer

Is there a way to store the media stream object in redux? using redux thunk or anything?

I'm working on a react project and we have a video media streams and I want to store the stream objects in my redux store but as far as I know storing non-serializable objects is not a good practice for redux, but I found some answers on google…
1
vote
1 answer

What is the correct way to call updateCachedData on a click event in a component that uses the RTKQ query?

I can only think of storing a reference to updateCachedData somewhere globally and use it in that click event but I am not sure this is the React way of doing this. I have a notifications feed built with a Socket.IO server. By clicking on a…
silviubogan
  • 3,343
  • 3
  • 31
  • 57
1
vote
2 answers

Manually trigger RTK query or mutation inside a Redux Saga task

I use Redux-Saga in situations where there is complex business logic that is best separated from the component. We are adopting RTK Query and aren't able to use the endpoints manually. Yes, I am aware that Redux best practices docs suggest using…
agusterodin
  • 417
  • 1
  • 5
  • 17
1
vote
1 answer

What is the correct way to stop receiving streaming updates from an RTKQ?

I tried to call an unsubscribe function: unsubscribeFromThingIds(arg.tids); after the await cacheEntryRemoved; line in this example. The function is defined like this: export const unsubscribeFromThingIds = (tids: string[]) => { followedThingIds…
silviubogan
  • 3,343
  • 3
  • 31
  • 57
1
vote
2 answers

React/Redux can store state be manipulated on the front-end side?

I have just some general question about react (or rather redux) store security: Is it possible to manipulate the store state somehow from the frontend side? E.g set some "isLoggedIn" or "isAdmin" property to true from the frontend? I suppose the…
MMMM
  • 3,320
  • 8
  • 43
  • 80
1
vote
0 answers

How to include React-Admin In Another Redux Application

I'm trying to embed react-admin into another redux application. The docs outline how to do this here. However, the main app located here uses configureStore rather than createStore. Moreover, createStore in the react-admin docs passes in state…
pandichef
  • 706
  • 9
  • 11