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.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
21 views

REACT: How to update the information in initialState: {} in @reduxjs/toolkit

In a createSlice component, I am trying to call a reducers function that changes a part of the initialState called selected but when I try to access it after breaking it down like const { selected: ...
Ese10's user avatar
  • 15
1 vote
1 answer
25 views

React-Redux-axios-Typescript: ERROR Cannot read properties of undefined

I'm a backend dev, and not too familiar with frontend development, just making some front for solo project... So I'm trying to login user right after setting password. Here's my code: This is from ...
yerokha's user avatar
  • 11
0 votes
2 answers
26 views

React Redux Toolkit: Naming convention between slice and store

I hope that finally someone can answer my question ... which is more of a general "good to know" question rather than a vitally important one :-) I cannot for the life of me find a definite ...
devnull69's user avatar
  • 16.3k
0 votes
1 answer
11 views

Setting Up a Reusable Test Render Function in redux toolkit v2

Below function works well as a redux toolkit test render wrapper before the redux toolkit v2. but with the release of v2 EmptyObject type is missing (so it's required all the reducers to be defined ...
Shehan Rangana's user avatar
1 vote
2 answers
36 views

How to edit a slicer to call functions using CRUD?

I can’t figure out how to call functions in components, passing them as parameters. For example, to receive a full tour or removal. So that it is updated on the backend and in the store. This is my ...
dmtrmkhlv's user avatar
1 vote
1 answer
33 views

Redux Toolkit - How useSelector is referring to initialState through reducer?

I'm trying to understand (ineffectively) how does useSelector refers to initialState stored in Slice with the line const count = useSelector((state) => state.counter.value) Referring to ...
Adrian's user avatar
  • 13
-1 votes
0 answers
11 views

Can we call an external pure function inside a redux reducer?

Is it a good practice to call external functions inside a reducer? In the below example, I have called pure functions printSomething() and stateIncrement() inside the increment reducer. This works ...
Gautham Muralidharan's user avatar
-2 votes
1 answer
41 views

How to store (class) instances objects in a Redux environment (if you really have to) [closed]

Redux says it's essential to only store serialisable objects in your store. Also the accepted answer to a SO question on how to store non-serialisable data, is "you don't". However I have ...
Claude's user avatar
  • 9,102
1 vote
1 answer
35 views

Why am I getting 'A non-serializable value is detected in the state' warning?

I was making a movie review app where I used Redux for storing and fetching the data, even though I left my state empty this error was still showing. Below is the code of the redux movie store. import ...
ashutosh singh's user avatar
0 votes
1 answer
18 views

How to adapt to Redux Toolkit's Updated selectById Type in EntitySelectors

I've recently updated "react-redux": "8.0.4" to "8.0.5" and "@reduxjs/toolkit" from "1.8.6" to "2.0.0". In doing so I've noticed a change in ...
singlservinjack's user avatar
0 votes
1 answer
31 views

Redux Toolkit matching utilities (isAllOf) not capturing the state change

I'm following the example in the official doc Matching Utilities, and trying to use isAllOf to update state when all the API calls have been successfully made. All the parameters will be created by ...
GoldenArcher's user avatar
1 vote
1 answer
41 views

React Redux : Why dispatching causing my local component states to reset

I'm currently working on a ReactTS Project (v18.2) using Redux Toolkit (v.1.9.7) to handle my store I don't understand why when I dispatch something into my store, local states of my component are ...
S1p's user avatar
  • 11
-2 votes
0 answers
56 views

"ReferenceError: Property 'WeakRef' doesn't exist, js engine: hermes" when using with expo sdk 49 with @reduxjs/toolkit [closed]

Please refer to this issue that I have opened on the github of redux-toolkit package https://github.com/reduxjs/redux-toolkit/issues/3943 I am using Expo SDK 49 React Native with hermes engine. I kept ...
Preetam's user avatar
0 votes
2 answers
40 views

What is typescript doing with the "=" in the function "export const useAppDispatch: () => AppDispatch = useDispatch"

Working on react app with react-redux + react-toolkit and I ran into some typescript syntax that puzzled me. export type RootState = ReturnType<typeof store.getState> export type AppDispatch = ...
Leviathan_the_Great's user avatar
0 votes
1 answer
34 views

problem with mocking useAppSelector for testing with Jest, RTL, Redux Toolkit, React

I have react redux toolkit installed and I've added jest instead of vitest for testing. I want to test that modal window is rendered in App component, if isOpen flag is true. I'm mocking only the part ...
George Tsintsadze's user avatar
-1 votes
0 answers
19 views

State not synchronously updated with React custom hook and Redux toolkit/persist [closed]

I'm making a blog website, using React/Redux & NodeJS. I was implementing server side error handling for sign-in/up form to display error messages for users. I realize if there was a previous ...
devsee's user avatar
  • 1
-2 votes
0 answers
25 views

data initialization in redux toolkit + nextjs 14 [closed]

well. this might be a silly question but, im using redux-toolkit with nextjs version 14. this is my authSlice.tsx import { PayloadAction, createSlice } from "@reduxjs/toolkit" const ...
Mohamadreza Kazemian's user avatar
-1 votes
1 answer
86 views

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'user')

While registering a user I am getting this error. Apparently I must be forwarded to the login page after registering the user but I am getting this error. Looks like the problem is with fetching the ...
H_R_S's user avatar
  • 11
-2 votes
0 answers
31 views

Redux Toolkit Typescript, A mistake I don’t understand

He added "@reduxjs/toolkit": " 1.9.7" and "react-redux" + typescript to his project. The project itself is Vite + TypeScript + React + ReduxToolkit. There was an error: ...
SMax's user avatar
  • 1
-1 votes
0 answers
34 views

In React using Redux, how do I force a re-render when an attribute of an object stored in state changes? [closed]

I'm using React 18. I manage my state through Redux and have defined this reducer ... saveSender: (state, action: PayloadAction<Contact>) => { state.orderItem.sender = action.payload }, ...
Dave's user avatar
  • 15.1k
-1 votes
1 answer
37 views

Not able to access auth state in Redux

I am not getting why I am getting undefined error, can someone help me to fix why I am not able to access auth state? src/queries/authSlice.jsx : import { createSlice } from "@reduxjs/toolkit&...
Sanad Qazi's user avatar
1 vote
1 answer
20 views

How to set expected response from server only status and cookie

I use Redux Toolkit Query to refresh occasionally jwt token: import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; export const refreshApi = createApi({ reducerPath: &...
Denys Garbuz's user avatar
-1 votes
0 answers
22 views

how to custom multi baseQuery in one file?

I have a requirement where I need to call APIs from various domains. However, I don't want to write a customized baseQuery for each new domain. Is there a way to default to calling http://abc and only ...
jan's user avatar
  • 55
3 votes
1 answer
70 views

Using useSelector value in function property

I have a React application that relies on the value produced by a useSelector listener within a function that I pass as a property to a child component: import React from "react"; import { ...
Ryan M's user avatar
  • 153
-1 votes
1 answer
42 views

Update some nested object of state in reducer

I have a state like this in a createSlice reducer. It is not stated anywhere in redux document examples, they are only about assignments of primitive properties. So, is it fine to assign action....
lockedscope's user avatar
-1 votes
0 answers
32 views

Getting error whein i run and open my app first time after reload it automatically fix the error im using NEXT.js 13 [closed]

i get this below error when i run my default page under app/page.js More im using redux and im fetching data from server so i make it client side rendering page. ` :3000/_next/static/c…nks/app/page.js:...
Faisal Rehman's user avatar
-1 votes
1 answer
53 views

How do I make my carousel respond to url changes?

I have a gallery, that opens individual images in a carousel. Unfortunately, I can't make it respond to URL path changes. const { signatura } = useParams(); const selectedPhotoIndex = useSelector(...
Andrija Vranić's user avatar
0 votes
0 answers
39 views

store.getState() is empty on server-side. "next-redux-wrapper"/"redux-toolkit"

Ok, hi everyone. I require assistance realy bad. I`m trying to implement "next-redux-wrapper" into my portfolio project. Result i wanna reach: const PortfolioRoute = ({ status }) => { ...
OmegaPepega's user avatar
1 vote
2 answers
41 views

What is the use of extra and extraoptions in Redux-Toolkit Query? How could we populate them when using the query & queryFn?

I am just curious to know the way to populate extra and extraOptions, and from where the arguments must be passed in order so that they can get populated and can be used then in creating some ...
shawnMarkus's user avatar
1 vote
1 answer
35 views

Redux useSelector hook always return an empty array

I have a react component like this, where I have a websocket set up, and on websocket events I am trying to update state inside of Redux const Body = () => { // Hook for Redux dispatch ...
RedRum69's user avatar
-1 votes
0 answers
19 views

Redix Toolkit Query - parallel requests

I am writing react-native app using rtk query for handling remote state. I have two APIs: export const restaurantApi = createApi({ reducerPath: 'restaurantApi', baseQuery: fetchBaseQuery({ ...
Aykut's user avatar
  • 1
1 vote
1 answer
39 views

Integration testing of my app that uses RTK Query to get/update data from/to firebase. I am using Typescript

I need help in testing my food ordering app that uses RTK Query to get/update data from/to firebase. I am stuck as I am not sure if I can wrap my actual redux store that has reducers(RTK Query) while ...
Ranjana Singanoodi's user avatar
0 votes
1 answer
51 views

rtk query is not a function

I am encountering a problem while attempting to perform a GET request using RTK Query. The current configuration I have is as follows: api.ts // Basic api setup import { createApi, fetchBaseQuery } ...
Gregoris Baxtsevanos's user avatar
-1 votes
0 answers
28 views

How to implement a save-on-unfocus/save-on-click-outside-component functionality in react-native?

I have a container component that fetches data from a database using RTK Query and then renders a FlatList using the data. The data (referred to as "items") returned has the following ...
VaniCodes's user avatar
1 vote
0 answers
48 views

Redux state change does not trigger React component rerenders

this is an adapter called pairings import { createEntityAdapter } from '@reduxjs/toolkit'; // For now will use row ID as the Pairing_ID since it does not exist export const pairingsAdapter = ...
RedRum69's user avatar
-1 votes
0 answers
41 views

how to assign a value returned from a promise function in redux-toolkit

I am using redux toolkit inside react native app , its multi language app where user would be able to switch between languages , default language in redux store is "en", I want the default ...
salmanaacvf's user avatar
-1 votes
0 answers
61 views

Removing an object from React Redux Reducer does not update state

I am using React, Redux and Redux Toolkit I am defining something called pairingsForEdit This is the Adapter for it made with createEntityAdapter from Redux Toolkit import { createEntityAdapter } from ...
RedRum69's user avatar
0 votes
0 answers
18 views

Redux DevTools shows unexpected repetition of ALL_PRODUCT_REQUEST after API call

I'm facing an issue with my Redux setup where, after dispatching ALL_PRODUCT_REQUEST in my getProduct action and successfully fetching data from an API, the same action (ALL_PRODUCT_REQUEST) seems to ...
VMS's user avatar
  • 21
-1 votes
1 answer
51 views

Component render every page reload

I have project with TS+REACT+REDUX TOOLKIT and i fetch some data to my items array. Then using redux toolkit i give to filterMenu (alphabet and birthday filter) and filterSearch (input search) data to ...
Anan Poinf's user avatar
-1 votes
0 answers
31 views

Action order with redux-toolkit, thunks and listener middleware (with firebase auth)

Problem Presently, when logging in with firebase authentication (for web), the action setStateByAction is dispatched before setName. I would like the action setStateByAction to be performed after ...
saner's user avatar
  • 406
2 votes
0 answers
39 views

How to properly return error from createAsyncThunk [duplicate]

I am trying to return the error inside of my createAsyncThunk axios response. Im not able to trigger .catch in the caller dispatch if axios returns an error. How can I get .catch to catch the error ...
jjyj's user avatar
  • 437
1 vote
2 answers
66 views

Redux initial state is has values, but it shows null in redux dev-tool. Why?

I've been getting this error where I have set the initialState of redux with a value, but while debugging it shows its value is null. I'm using Redux Dev-tools to check the values. And also while ...
Ayush Parui's user avatar
1 vote
2 answers
51 views

passing types to initialState in slice

I did this dictionary project fine using Props. Now I am trying to do in redux-toolkit. I have types in a separate file export type searchType = { word: string; } export type meaningsType = { ...
user3269443's user avatar
-2 votes
1 answer
61 views

Problem when using FlashList in React Native?

this code is supposed to load infinite data using pagination with RTK Query and Flash list. Data is coming normally without issues the only issue is it loads all data at once and ignores the ...
Marco's user avatar
  • 848
1 vote
1 answer
97 views

getting the changed value in state

I have a project that sends values to a server when the state changes via websocket and i'm using redux-toolkit and I have a state like this const initialState = { exposure: false, whiteBalance: ...
alexander fijjek's user avatar
0 votes
0 answers
35 views

Not getting data using useEffect in react but get endpoint is working as tested using postman

I am trying to get data from Mongo DB using fetch GET request. I am using useEffect to get data as shown below. import React, { useEffect } from "react"; import { useDispatch, useSelector } ...
Vishal's user avatar
  • 7
0 votes
0 answers
18 views

RTK Query manual cache updates for list and single queries

I've been working with RTK Query for a short time. I'm currently trying to find a solution to the following problem. I have defined the following API. export const teamApi = coreApi.injectEndpoints({ ...
LucaToni04's user avatar
0 votes
1 answer
28 views

What is the correct way to type an rtk query BaseQueryFn with custom DefinitionExtraOptions?

I want to use custom base query, and supply it with extra options. Here's a toy example: import { BaseQueryFn, createApi } from '@reduxjs/toolkit/query/react'; const baseQueryTest: BaseQueryFn< ...
Max Yankov's user avatar
  • 12.8k
2 votes
1 answer
54 views

React useState not rendering the current onClick

I have a quandary on the code I'm trying to execute. I'm using controlled inputs and I'm passing the response from an API to a child component, but it is rendering the last value. Here is my code. ...
cruz's user avatar
  • 79
0 votes
0 answers
31 views

RTK Query manual cache update for endpoint where query key is generated through serialization method

We have Two RTK query where one is get query which save data in cache using serialization method and other mutation where on successful update at backend we want to update the cache manually in ...
CAJ's user avatar
  • 1

1
2 3 4 5
72