Category "redux"

React.js: How to get and show current user when logged in?

In my React app I am working in user login. My goal is to show current user's username when the user is logged in. I'm fetching the user data in redux actions a

React.js: How to get and show current user when logged in?

In my React app I am working in user login. My goal is to show current user's username when the user is logged in. I'm fetching the user data in redux actions a

Optimistic updates for item create in RTK Query

Can't figure out how to get optimistic updates to work properly when I'm creating a new item rather than updating the existing one. The optimistic updates do wo

reduxtoolkit mocking store with typescript

I found this code from redux documentation // test-utils.jsx import React from 'react' import { render as rtlRender } from '@testing-library/react' import { con

Store redux data that can be accessible with swift and java

I want to rewrite my React Native application with Java for Android and Swift for iOS. The thing is, I don't want to lose application data so that the user has

What is wrong with my reselect function ? I dont get an output

I want to use reselect. I want to get my shopping cart by the ids. reselect.ts import { createSelector } from "reselect"; import { RootState } from "../store";

Redux toolkit: Uncaught TypeError: Cannot read properties of undefined (reading 'type')

I get the following error when I add a specific action in the extraReducers inside a slice: Uncaught TypeError: Cannot read properties of undefined (reading 'ty

How to fix circular dependencies of slices with the RootState?

I recently started using redux-toolkit and started writing my reducers using the createSlice following their docs. One reducer, let's call it reducerA, imports

How to remove an item from Local Storage when clicking on it? [duplicate]

I want to delete an item stored in Local Storage when it is clicked. But I don't know how to do that. Please help me to solve this problem. Th

How to fix 'The previous state received by the reducer...'?

I load/update data in localStorage: import thunk from "redux-thunk"; import {applyMiddleware, createStore} from "redux"; import {composeWithDevTools} from "redu

React Material Table : onRowAdd not refreshing

I am using Material Table for displaying table data. Using onRowAdd, I am able to add a new row but the page is not refershing. It reloads and get stuck then I

Redux-persist does not work with Redux-Toolkit

The app works fine The only thing is that redux persist is not working as it should.Persist doest not persist anything,it does not give any errors in the consol

componentDidMount affects other component

I have a price counter component. When I try to decrease a product qty to 0 it is deleted successfully but it affects the following product's qty and gives it 0

useSelector and map function React Redux

i want to iterate through an array but Im not sure if i can do this in the useSelector redux hook because it's not giving me the result that i want. Have any o

Entity adapter getSelectors method generates "Cannot read property 'map' of undefined" error

I am trying to use createEntityAdapter from reduxjs/toolkit to generate selectors automatically. I have created a "select all" selector successfully using creat

Cannot update a component while rendering a different component warning

I am getting this warning in react: index.js:1 Warning: Cannot update a component (`ConnectFunction`) while rendering a different component (`Register`). To l

redux saga api call is getting executed multiple times for single button click

I am newbie in Redux Saga, trying to make an API call through Saga but it gets triggered multiple times. Below is my code. component.js (dispatch action inside

How to set initial state for redux reducer in typescript?

I am getting this TypeScript error Property 'hasError' does not exist on type '(state: ErrorType | undefined, action: ErrorActionType) => ErrorType'. which I

How to use redux toolkit's preloadedState and createSlice together properly?

I am trying to migrate to redux toolkit, but just encountered an issue. Here's an example of simple counter slice. import { createSlice } from "@reduxjs/toolkit

Firebase error: No firebase app default has been created

I am making a food delivery app using react-native and redux. I want to fetch the data from the firebase store and for that, I have written a function in the ac