Miscellaneous Flashcards

1
Q

What are React Portals?

A

Portals provide a way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

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

How do you handle forms in React?

A

Using controlled components where form elements like <input></input>, <textarea>, and <select> maintain their state in the React state.</select></textarea>

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

What is the significance of the key prop in React lists?

A

Keys help React identify which items have changed, are added, or are removed, which aids in efficient updates and rendering.

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

What is a Fragment in React?

A

Fragments allow a component to return multiple elements without wrapping them in a parent DOM element.

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

What are React hooks?

A

Hooks are functions that let you “hook into” React state and lifecycle features from function components.

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

What is Redux and how does it relate to React?

A

Redux is a predictable state container for JavaScript apps.

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

What is mutability?

A

The ability of an object to be altered or changed after its creation.

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

What are pure functions?

A

Functions that always produce the same result given the same inputs and produce no side effects.

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

What is functional programming?

A

A programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state or mutable data.

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

How does immutability differ from mutability?

A

Immutable objects cannot be changed after creation, promoting safer and more predictable code. Instead of altering, new versions are created.

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

What’s the benefit of immutability in React?

A

It simplifies complex features like time-travel debugging, ensures consistent behavior in your components, and can improve performance optimization.

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

What is tree shaking?

A

A method used by modern bundlers to eliminate dead code by analyzing which exports are used and which are not.

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

Why is tree shaking beneficial?

A

It reduces the final bundle size, leading to faster load times and better performance for web apps.

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

What is code splitting?

A

A technique where a large bundle is split into smaller chunks that can be loaded on demand, optimizing load times.

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

How does React support code splitting?

A

Through features like React.lazy() and <Suspense>, allowing components to be loaded dynamically.

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

Define Polyfill.

A

A code piece added to provide modern functionality on older browsers that do not natively support it.

17
Q

What’s the purpose of a Virtual DOM?

A

A lightweight in-memory cache of the actual DOM on the page, allowing for efficient updates and rendering by minimizing direct DOM manipulations.

18
Q

How does React use the Virtual DOM?

A

React creates a diff between the current Virtual DOM with the previous one and updates only the actual DOM nodes that need to change, optimizing performance.

19
Q

What is the principle of Single Responsibility?

A

An object (or function, or module) should have only one reason to change, promoting cleaner, more maintainable, and easily understandable code.

20
Q

What is a Higher-Order Component (HOC) in React?

A

A function that takes a component and returns a new component with added props or altered behavior.