React Flashcards

1
Q

What is React

A

An open-source JavaScript library used for building user interfaces. Allows developers to create reusable UI components and efficiently update and render them as the application state changes.

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

What are the key features of React.js?

A

Virtual DOM, Component-base architecture, Unidirectional data flow, JSX and supports server-side rendering

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

What is JSX?

A

Is a syntax extension for JavaScript used in React.js. Allows you to write HTML-like code directly within JavaScript.

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

Difference between function and class components

A

Function components are stateless and defined as JavaScript Functions. Class components, are defined as ES6 classes and have additional features like lifecycle methods and state management.

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

What is the difference between a controlled and an uncontrolled component?

A

Controlled component is a component whose state is controlled by React. Receives its current value and change callbacks as props and notifies parent components of state changes. Uncontrolled component stores its own state internally and manages it through the DOM.

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

What is the significance of the “children” prop in React?

A

A special prop that allows components to display whatever is included between their opening and closing tags.

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

What is the difference between props and state.

A

Both used to mange data. Props are read-only and passed from parent to child component. State is mutable and is managed internally within a component. Used to manage data that can change over time within a component

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

Significance of the virtual DOM?

A

Is a lightweight copy of the actual DOM. When there is a change in application state, it is compared to real DOM and only updates the necessary part.

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

What are React Fragments

A

Allow you to group multiple elements together without adding an extra DOM.

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

What is Context API in React?

A

Creates a global state accessible to any component within a designated context.

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

Explain the concept of prop drilling in React.

A

Process of passing props through multiple layers of components in order to reach a deeply nested component that needs to access the data.

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

How does React handle list and keys

A

Each item in the list should have a unique “key” prop assigned to it. The “key” prop helps React identify which items have changed, been added, or been removed. Keys improve the efficiency of list rendering and help maintain component state correctly.

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

What are React hooks

A

Are functions that allow functional components to use state and other React features without a class.

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

What is the purpose of useEffect hook

A

Is used to perform side effects in a React component.

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

What is the role of the useState hook

A

Is used to add state to functional components. Returns an array with two element, the current state value and a function to update the value.

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

What is the purpose of useCallback hook

A

Used to memorize functions, returns a memorized version of the callback function that only changes if one of the dependencies has changed.

17
Q

What is React Fiber

A

Is a re implementation of React’s core algorithm for rendering and updating components.Introduced to improve performance, enable incremental rendering and better support concurrent mode

18
Q

What are portals in React.

A

Allows you to render components at a different positions on the DOM tree, which can be useful for modals, tooltips, and overlays.

19
Q

Explain the concept of code splitting in React

A

Is a technique used to split a React application’s JavaScript bundle into smaller chunks. It allows you to load only the required code when needed.

20
Q

Explain the concept of error boundaries in React.

A

React component that catches JavaScript errors in their child compoent tree and display fallback UI instead of crashing the whole application. Helps isolate errors and provide bettwer user experience.

21
Q

What is the purpose of “React.StrictMode”

A

Helps highlight potential problems and deprecated features in the application code

22
Q

Explain the concept of higher-order components

A

Functions that take a component as input and return an enhanced version of that component.

23
Q

What is a state in React?

A

Is an object that holds some information that may change over the lifetime of the component. When the state object changes, the component re-renders

24
Q

What are the components in React?

A

Reusable and self-contained module that represents a part of the user interface. It can be a function component or a class component

25
Q

Why use React instead of other frameworks, like Angular?

A

Easy creation of dynamic application, Improved performance through virtual DOM, Reusable components, unidirectional data flow, dedicated tools for easy debugging and massive community.

26
Q

Can web browsers read JSX directly?

A

Because web browsers are built to only read regular JS objects and JSX is not a regular JavaScript object. File needs to be transformed into a regular JavaScript object. For this, we use Babel

27
Q

How can you handle events in React

A

Handle events by providing event handlers as props to elements. React uses synthetic events that wrap the native browser events and provide consistent behavior across different browsers.

28
Q

What is Reconciliation?

A

Reconciliation is the process through which React updates the Browser DOM

29
Q

What is the difference between Shadow DOM and Virtual DOM?

A

Shadow DOM is a web standard provided by browser primarily used to encapsulate HTML, CSS and JavaScript. While the Virtual DOM is a concept used in some JavaScript libraries (e.g., React) which involves keeping a virtual representation of the UI in memory and syncing it with the real DOM through a reconciliation process.

30
Q

What is useRef

A

Is a React Hook that lets you reference a value that’s not needed for rendering. Typically used when you need direct access to a DOM element or an instance of a component.

31
Q

What is context API

A

Context provides a way to pass data through the component tree without having to pass props down manually at every level.

32
Q

What are Disadvantages of React?

A

Fast changes and updates makes it difficult to create documentation, and required constant relearning. SEO Problems. it is just a view library.

33
Q

Why is Vite so fast?

A

Vite use ESM for on-demand file serving and compilation during development, ensuring that only changed or requested files are processed.