Published on

Redux Topic .md file

Authors
  • avatar
    Name
    Ganesh Negi
    Twitter

What is Redux ?

Redux is an open-source JavaScript library used for state management.

Redux provides a centralized store that holds the entire state of an application and allows components to access and update the state in a predictable manner.

What is the flow of data in React using Redux ?

  1. When data enters the system that is through the API or the UI that users enters.
  2. Actions are dispatched. you have a type and the payload in actions, and you sent dispatch it to the Redux store,
  3. Reducers process the data. It receives the data. It set the payload to some specific key in the store.
  4. The new state is stored in the store, Once the redux store is updated, all the components inside your application are triggered through props. And if you have registered a listener on that prop you will get the new data.

What is the role of Store in React Redux ?

The store where all the state of an application is stored. This ensures the state is predictable and persistant for the whole application.

What is the role of Reducer in Redux ?

A Reducer is a function that takes the previous state and an action as arguments and returns the new state of the application.

Explain the Core Priniciples of Redux ?

  1. SIngle Source of Truth (Store)

  2. State is Read-only (Unidirectional)

  3. Changes using Pure Functions (Reducers)

  4. Actions Trigger State Changes (Actions)

  5. Predictable State Changes (Actions)

What are the differences between local component state & Redux State ?

Local Component State

  1. Scope: Limited to the component where defined.
  2. Management: Managed internally by the component.
  3. Performance: Generally, more performant for small-scale applications.
  4. Complexity: Simpler to set up and manage.

Redux State

  1. Global and accessible across components.
  2. Managed externally by the Redux store.
  3. More performant for large applications.
  4. Comparatively complex to manage.

What are the disadvantages while using Redux ?

What is Provider Component ? How components getting the state from Redux store ?

Provider component of react-redux will make the Redux store available to all connected components.

What is the role of Connect function in React-Redux ?

The connect function is used to make the connection between a React component and the Redux store.

Explain the concept of Middleware in React-Redux ?

Middleware provides a mechanism to add extra functionality to the Redux store.

Middleware can intercept actions, modify them, or execute additional logic in actions before they reach the reducers.