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
1 answer

Using redux / toolkit for state slicing between components

I am stuck on an issue with my SlideShow with Redux , which I am new with. I am trying to figure out the logic to connect my dropdown select and the next and previous buttons so that redux keeps track of my state. I want the user to be able to…
lache
  • 608
  • 2
  • 12
  • 29
1
vote
2 answers

delete item from apiCall need reload page to deleted from client

i use redux toolkit with react native and mongodb (mongoose) i delete item and it successfully deleted from db but not in client and need to reload page todoSlice : import {createSlice} from '@reduxjs/toolkit'; export const todoSlice =…
1
vote
2 answers

How to get an RTK Query API endpoint state (isLoading, error, etc) in a React Class component?

Ok, I think I've gone through almost all of RTK Query's docs, and read up on RTK Query's caching. Seems like it's a pretty big part of it, even if its not something I need at the moment. So, I'm trying to do a simple query using RKT Query in a…
sgarcia.dev
  • 5,671
  • 14
  • 46
  • 80
1
vote
2 answers

Why can't I update the state using Redux?

I'm trying to integrate Redux in a project that works already. I've configured the Redux store using multiple slices, here's the one causing troubles: const initialCategoriesState = []; const categoriesSlice = createSlice({ name: "categories", …
1
vote
0 answers

Typescript compile error in Redux Toolkit createAsyncThunk.ts

I am having trouble with Typescript and Redux Toolkit. My code seems to be ok, but I am getting this error: /home/mp/JsProjects/myproject/node_modules/@reduxjs/toolkit/src/createAsyncThunk.ts TypeScript error in…
Peter Molnar
  • 123
  • 2
  • 7
1
vote
1 answer

Redux Toolkit + RTK + Multer

How upload an image with RTK and Multer ? JSX file const onSubmit = (e) => { e.preventDefault(); const payload = new FormData(); payload.append("imagegif", image); payload.append("title", formData.titre); …
Nicolas Popy
  • 51
  • 1
  • 7
1
vote
1 answer

What to use as global state manager in React NextJS?

I am using NextJS and would like to know what is the best global state manager to use. ContextAPI or Redux - Toolkit. Looking for an answer in the Internet, I got the impression that ContextAPI is used more often. But for some reason I'm not sure if…
Gregory Kafanov
  • 339
  • 1
  • 3
  • 11
1
vote
1 answer

Is it okay to use same handler for different redux actions?

I use redux - toolkit in my app with createAsyncThunk. I have some "cart" reducer and inside it I have "CART_CLEARED" action. "CART_CLEARED" is being called when user press on "Clear Cart" button. But now, I also have to clear cart when user made…
eugenedrvnk
  • 408
  • 1
  • 5
  • 10
1
vote
0 answers

Redux Toolkit: How to update state inside reducer after fetching data from the server?

I have a couple of reducer functions inside my checkoutSlice.js file. Specifically inside fetchCheckout function I'm trying to fetch data (it's successfully fetching) and store it in the state as checkout. But for some reason it gives me this…
dima
  • 153
  • 1
  • 7
1
vote
1 answer

How can I keep my useSelector() variable from a redux store updated after each dispatch?(Redux Toolkit)

So I'm using React Native with Redux Toolkit and I'm facing this issue where once I dispatch and decrement a store value, the variable inside the component that grabs the state from the store does not update until the next render. It would be nice…
1
vote
2 answers

Is it possible to select multiple entities from redux store by passing an array of keys in useSelector?

For your information, I have following code: const companyPagesAdapter = createEntityAdapter( { selectId: model => model.pageNumber, sortComparer: (a, b) => a.pageNumber>b.pageNumber? 1 :…
Dima Kambalin
  • 283
  • 2
  • 12
1
vote
0 answers

How to solve TS circular reference issue with ES6 import/export syntax but still keep inferred static type?

I have the situation "A imports B and B imports A". I've put the code of both files in one file and moved one of the file's relevant content into a variable declaration (not definition) almost at the beginning of the file. I've practically solved…
1
vote
1 answer

What should I use redux-saga or redux-thunk in 2021?

Which one should I use? For more context I use redux-toolkit. Advices to help understand which tool fits better are appreciated
Dima Kambalin
  • 283
  • 2
  • 12
1
vote
1 answer

Connecting Redux Stores using Redux Toolkit

for various reasons, my workplace is currently trying to introduce React/Redux into our project. Our project utilizes Shopify and it's Liquid templates along with jQuery. They want to migrate towards React, and we have thus far been injecting…
asegier
  • 55
  • 5
1
vote
1 answer

Redux Toolkit Query (RTK Query) ignoredPaths- any examples?

Is there any documentation on the format for the paths in ignoredPaths? is it the url for the specific endpoint and method?