Code Skiller logoCB Logo
Logo LearnLearnLogo PracticePracticeLogo HireHireLogo IDEIDE

Introduction to Redux

User image

Published by

sanya sanya

Published at: 28th Jul, 2023
1.73 mins read

Redux is a state management library for React and other JavaScript applications. It helps manage the state of an application in a predictable, centralized way, making it easier to reason about and maintain complex state interactions.

Redux follows the principles of Flux architecture and is often used with React to manage the state of the entire application or parts of it. Redux's core concepts are the store, actions, reducers, and optionally middleware.

Core Concepts

  • Store - The store is the central data repository for the application state. The Store holds the entire state tree of the React application which is created using the createStore function. Components can access the state stored in the store and subscribe to changes to the state.

  • Actions - Actions are plain JavaScript objects that represent events in your application. They are used to describe what happened in the application and carry the necessary data for state changes.

  • Reducers - The Reducers are the pure functions which take the current state with an action as input and returns a new state. They define how the state changes in response to actions. Reducers are combined to form the root reducer, which will be used to update the store.

  • Middleware - Middleware lies between the dispatching of an action and the moment it reaches the reducer. It is optional and is useful for tasks like logging actions, making async calls, or modifying actions before they reach the reducers. Popular middleware includes redux-thunk for handling async actions and redux-logger for logging actions.

Basic Flow

  • Components in the React application dispatch actions to the Redux store using the dispatch function.

  • The actions are passed through any middleware if present, which can perform additional tasks.

  • The reducers take the current state and the action, and based on the action type, return a new state.

  • The new state is then further stored in the Redux store.

  • Components subscribed to the store will be notified of the state changes and can re-render accordingly.

Library

WEB DEVELOPMENT

Basic

Frontend

Express JS

React

Hello World in ReactJS

Rendering Elements

States and Lifecycles in React JS

Handling Events in React JS

Introduction to JSX

Components and Props in React JS

Conditional Rendering

Lists and Keys in React JS

Introduction to Redux

Types of components (class vs functional)

Using the useEffect hook

Building custom hooks in React JS

Context API in React JS

Forms in React JS

Lifting State Up in React JS

Composition vs Inheritance

Prop drilling in React JS

Introduction to Hooks

Using the useState hook

UseMemo vs useCallback

Backend

Interview Questions

FAANG QUESTIONS

On this page

Core Concepts

Basic Flow