Questions tagged [redux]

Redux is a pattern and library for managing JavaScript application state, using events called "actions". It serves as a centralized store for state that is needed across your entire application, with rules ensuring that the state can only be updated in a predictable fashion. Redux make it easier to understand when, where, why, and how the state in your application is being updated, and how your application logic will behave when those changes occur.

Redux is a pattern and library for managing and updating application state, using events called "actions". It serves as a centralized store for state that needs to be used across your entire application, with rules ensuring that the state can only be updated in a predictable fashion. It is inspired by the architecture.

The patterns and tools provided by Redux make it easier to understand when, where, why, and how the state in your application is being updated, and how your application logic will behave when those changes occur. Redux guides you towards writing code that is predictable and testable, which helps give you confidence that your application will work as expected.

Redux Toolkit 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


Useful Links

Related tags

35457 questions
7
votes
1 answer

How to implement buttons inside a AG grid rows in react

I want to implement a AG grid table with a name, type columns. I want to add one more column "edit" in the table, and allow users to edit&delete the rows from the table. It will look like this: I get my data from the redux store, this is the way I…
mr_nocoding
  • 472
  • 7
  • 16
7
votes
2 answers

How to access React Redux value only once?

I just want to get a value once from the redux store, and use it once inside of a useEffect function. However useSelector is required to be on the root level of a component, so it is run every render. This means if the value in my redux store is…
Qrow Saki
  • 932
  • 8
  • 19
7
votes
1 answer

TypeScript: an interface property requires another property to be true

How can I define keys: a, b, c, bar as undefined/null/optional type if foo is false? In other words, I need these properties to be mandatory only if foo is true. interface ObjectType { foo: boolean; a: number; y: string; c: boolean; bar?:…
Vinay Sharma
  • 3,291
  • 4
  • 30
  • 66
7
votes
4 answers

Redux-toolkit action arguments in WebStorm

I started using redux toolkit, but when I try to dispatch an action with arguments I get a warning from IDE saying: "Argument type {...} is not assignable to parameter type {payload: {...}}" or "Invalid number of arguments, expected 2" I guess it…
7
votes
2 answers

Redux Toolkit: 'Cannot perform 'set' on a proxy that has been revoked'

I'm trying to recreate a Memory-like game with React. I'm using Redux Toolkit for state management, but I'm having trouble with one use case. In the selectCard action, I want to add the selected card to the store, and check if there's already 2 of…
Merig
  • 1,751
  • 2
  • 13
  • 18
7
votes
1 answer

manually modifying initialState and pass it to the store before every test?

I am trying to understand the process of react and redux testing, i am using testing library to use the dom node queries for testing my project, but i am still confused of the way i should test the redux implementations in my react project: I…
Code Eagle
  • 1,293
  • 1
  • 17
  • 34
7
votes
2 answers

Call reducer from a different slice Redux Toolkit

I've got an authSlice const authSlice = createSlice({ name: 'authStore', initialState, reducers: { logout(state = initialState) { return { ...state, isAuthenticated: false }; }, }, extraReducers: (builder) => { …
Jamie
  • 3,105
  • 1
  • 25
  • 35
7
votes
1 answer

Benefits of defining types in type definition files vs. in an ordinary type file

For application code, is it advisable to put Redux store types in state-slice.d.ts files? I inherited a codebase where all the core types have been placed in .d.ts definition files, but this is contrary to how I’ve come to understand the role of…
Baggio Wong
  • 357
  • 1
  • 8
7
votes
2 answers

Load the initial state with localstorage Redux + Next.js

I'm trying to load the initial state from localstorage to create store, but i got this error: ReferenceError: localStorage is not defined My store: const store = createStore(reducer, { userInfo: { isLogged: false, items:…
7
votes
1 answer

Why is there an error on createSlice when the initial state is null?

import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { AppInfo } from '../models'; const initialState: AppInfo | null = null; const appSlice = createSlice({ name: 'app', initialState, reducers: { selectApp(state, action:…
Cabage
  • 337
  • 2
  • 11
7
votes
1 answer

is it safe to set access token to redux state for persistent session in React Native?

I'm trying to figure out a secure way to persist session in react native. I have some sensitive data like access token retrieved from server that i'm planning to set to the redux state. I'm not sure if it is safe to set sensitive data like…
kaizen
  • 1,580
  • 4
  • 26
  • 50
7
votes
4 answers

A component is changing the default value state of an uncontrolled Slider after being initialized. Material UI Slider with Redux State

I am trying to run a redux action that fetches a db and store it in a state variable. I am then using this variable as a default for a Material UI Slider. I am initializing this default value (to avoid being null which usually solves the problem)…
Mohamed Daher
  • 609
  • 1
  • 10
  • 23
7
votes
1 answer

Does it hurt performance to use the react redux hooks in a list?

This question is specifically about the newer react redux hooks, particularly useSelector and useDispatch. Say you have one component that is a list and another component that is a list item. The list component contains a list of the list items. You…
lsdmt
  • 160
  • 1
  • 7
7
votes
1 answer

What are some common Redux Toolkit's CreateAsyncThunk use cases

Could somebody please explain to me what and how to use createAsyncThunk like I'm 9 years old? What is the action string for? Is it temporarily created for logic/path reasons and destroyed soon later? What can I do with the action strings/what do…
Jpark9061
  • 924
  • 3
  • 11
  • 26
7
votes
2 answers

No overload matches this call in saga call effect

I want to pass action.url string as a parameter of topicDummy function which return Promise, but It keeps show me No overload matches this call. The last overload gave the following error. Argument of type '(url: string) =>…
dante
  • 933
  • 4
  • 16
  • 39