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
147
votes
23 answers

React-Redux: Actions must be plain objects. Use custom middleware for async actions

Unhandled Rejection (Error): Actions must be plain objects. Use custom middleware for async actions. I wanted to add comments with every posts. So when fetch posts are run I want to call fetch comment API for all post. export function…
Rajib Ahmed
  • 1,473
  • 2
  • 7
  • 4
144
votes
6 answers

What is the difference between Next.js and Create React App?

I'm trying to figure out the difference between Next.js and Create React App (CRA). I know both are there to make our life easier while developing our front-end applications using React. After exploring some articles on Google, I found that the main…
DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
142
votes
7 answers

Is this the correct way to delete an item using redux?

I know I'm not supposed to mutate the input and should clone the object to mutate it. I was following the convention used on a redux starter project which used: ADD_ITEM: (state, action) => ({ ...state, items: [...state.items,…
CWright
  • 2,068
  • 2
  • 16
  • 20
140
votes
5 answers

Why is my onClick being called on render? - React.js

I have a component that I have created: class Create extends Component { constructor(props) { super(props); } render() { var playlistDOM = this.renderPlaylists(this.props.playlists); return (
{playlistDOM} …
jhamm
  • 24,124
  • 39
  • 105
  • 179
139
votes
6 answers

Typescript + React/Redux: Property "XXX" does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes

I'm working on a project with Typescript, React and Redux (all running in Electron), and I've run into a problem when I'm including one class based component in another and trying to pass parameters between them. Loosely speaking, I've got the…
Protagonist
  • 2,219
  • 2
  • 12
  • 12
139
votes
3 answers

How can I persist redux state tree on refresh?

The first principle of Redux documentation is: The state of your whole application is stored in an object tree within a single store. And I actually thought that I understand all of the principles well. But I'm now confused, what does application…
incleaf
  • 1,905
  • 3
  • 15
  • 13
136
votes
3 answers

Running CRA Jest in non-interactive mode

Update: my use case is mainly to run tests at CI, but overriding default CRA Jest parameters is something I'm generally wondering about. I'm running tests using the Jest, config that came with Create React App. It always launches into the…
AlexStack
  • 16,766
  • 21
  • 72
  • 104
135
votes
5 answers

Can I use RxJS vs Redux/context when trying to manage and access state in different components and handler methods

I know Redux is a better "implementation" of Flux, or better saying it's a redesign to simplify things (application state management). I have heard a lot about reactive programming (RxJS), but I haven't dived to learn it yet. So my question is: are…
Oswaldo
  • 3,296
  • 4
  • 25
  • 35
135
votes
11 answers

While debugging, can I have access to the Redux store from the browser console?

I have unit tests for my reducers. However, when I'm debugging in the browser, I want to check if my actions have been called correctly and whether the state has been modified accordingly. I'm looking for something like: window._redux.store ... in…
Andre Pena
  • 56,650
  • 48
  • 196
  • 243
134
votes
5 answers

Local package.json exists, but node_modules missing

I am trying to start a Redux application I just cloned from a GitHub repository. I tried to run it with the following command npm start I am getting this error > react-redux@1.0.0 start /home/workspace/assignment > webpack-dev-server --config…
Deepak Mahakale
  • 22,834
  • 10
  • 68
  • 88
134
votes
12 answers

Typescript complains Property does not exist on type 'JSX.IntrinsicElements' when using React.createClass?

I am using typescript to write redux application. var item = React.createClass({ render: function() { return (
hello world
) } }); export default class ItemList extends Component { render() { return (
roger
  • 9,063
  • 20
  • 72
  • 119
132
votes
4 answers

React + Redux - What's the best way to handle CRUD in a form component?

I got one form who is used to Create, Read, Update and Delete. I created 3 components with the same form but I pass them different props. I got CreateForm.js, ViewForm.js (readonly with the delete button) and UpdateForm.js. I used to work with PHP,…
Mike Boutin
  • 5,297
  • 12
  • 38
  • 65
128
votes
13 answers

React setState not Updating Immediately

I'm working on a todo application. This is a very simplified version of the offending code. I have a checkbox:

Writing Item

Here's the function…
lost9123193
  • 10,460
  • 26
  • 73
  • 113
125
votes
7 answers

React / Redux and Multilingual (Internationalization) Apps - Architecture

I'm building an app that will need to be available in multiple languages and locales. My question is not purely technical, but rather about the architecture, and the patterns that people are actually using in production to solve this problem. I…
121
votes
7 answers

How to trigger off callback after updating state in Redux?

In React, state is not be updated instantly, so we can use callback in setState(state, callback). But how to do it in Redux? After calling the this.props.dispatch(updateState(key, value)), I need to do something with the updated state…
Brick Yang
  • 5,388
  • 8
  • 34
  • 45