Interview Practise Flashcards

1
Q

What is React, and what are its key features?

A

Explain declarative views, component-based architecture, Virtual DOM, and unidirectional data flow.

  • JavaScript library for UI
  • Virtual DOM: React uses a lightweight in-memory representation of the DOM to update only the necessary parts efficiently, improving performance.
  • Single Page Application (SPA) is a web app that loads a single HTML page and dynamically updates its content as the user interacts
  • Component-Based Architecture: Applications are built as reusable, independent components, promoting modularity and ease of maintenance.
    -Unidirectional Data Flow: Data flows in a single direction, from parent to child components, ensuring predictable updates and easier debugging.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is JSX, and why is it used?

A

Discuss how JSX combines HTML and JavaScript for component rendering and its necessity for React.createElement.

  1. It allows developers to write HTML-like code within JavaScript, combining markup and logic in one file.
  2. JSX is transpiled into regular JavaScript by tools like Babel, enabling browsers to interpret it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Virtual DOM, and how does it improve performance?

A

Explain its role in reconciling changes with minimal real DOM updates.

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

What are the differences between functional and class components?

A

Highlight the simplicity of functional components and the introduction of hooks vs. lifecycle methods in class components.

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

How does state differ from props in React?

A

Discuss immutability of props and the mutable nature of state, including their roles in component behavior.

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

What is prop drilling, and how do you handle it?

A

Mention Context API or state management libraries (Redux, Zustand) to manage deeply nested props.

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

What are React Hooks, and why were they introduced?

A

Focus on state and lifecycle management in functional components, mentioning useState, useEffect, etc.

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

How does the useEffect hook work, and what are its common use cases?

A

Explain dependency arrays, cleanup functions, and scenarios like data fetching or event listeners.

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

What is the Context API, and when would you use it?

A

Discuss global state management for prop drilling avoidance.

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

How does React handle component re-rendering, and how can you optimize it?

A

Mention memoization (React.memo, useMemo, useCallback) and key props for efficient updates.

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

What are Higher-Order Components (HOCs) and Render Props?

A

Explain how these patterns enhance component reusability and encapsulate logic.

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

What are React portals, and why are they used?

A

Discuss rendering child components outside the DOM hierarchy.

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

What are some methods to improve the performance of a React application?

A

Talk about lazy loading, code splitting, React Profiler, memoization, and optimizing dependencies in useEffect.

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

What is the difference between controlled and uncontrolled components?

A

Explain form data handling via React state (controlled) vs. direct DOM manipulation (uncontrolled).

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

How would you test a React component?

A

Cover tools like Jest, React Testing Library, and the importance of unit, integration, and snapshot testing.

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