React/Redux Flashcards

1
Q

What is Redux?

A

Redux is a predictable state container for JavaScript applications. It is commonly used in front-end web development with frameworks such as React, Angular, and Vue. Redux is based on the Flux architecture and provides a centralized store for managing the state of an application.

The basic idea of Redux is to store the entire state of the application in a single object called the “store”. This store is immutable and can only be modified by dispatching actions. Actions are plain JavaScript objects that describe a change in the state of the application. They contain a “type” property that identifies the type of action and an optional “payload” property that provides additional data for the action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a state in React and how is it used?

A

The state is a built-in React object that is used to contain data or information about the component. A component’s state can change over time; whenever it changes, the component re-renders.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why can’t browsers read JSX?

A

Browsers can’t read JSX directly because it’s a syntax extension to JavaScript that is not recognized by browsers. JSX is a syntactic sugar for creating React elements that allows developers to write HTML-like code within their JavaScript files. However, browsers only understand JavaScript, HTML, and CSS, so they can’t parse JSX code directly.

In order to use JSX in a web application, developers must first compile their code using a build tool like Babel, which transforms the JSX code into regular JavaScript code that browsers can understand. Babel does this by parsing the JSX syntax and converting it into a series of function calls that create React elements. This transformed code can then be included in a web page like any other JavaScript code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In Redux, what do you understand by “Single source of truth”?

A

In Redux, the “single source of truth” refers to the concept that the entire state of an application is stored in a single JavaScript object, called the store. This means that all of the data that represents the current state of the application is located in one place, making it easy to manage and access.

The state in Redux is immutable, meaning it cannot be directly modified. Instead, any changes to the state must be made by dispatching an action to the store. The store then updates its internal state based on the action, and triggers a re-render of the application UI based on the updated state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly