React 101 Flashcards

1
Q

What is React and why is it used web development.

A

React is a Javascript library used for developing user interfaces. It’s used in web development to build interactive and efficient UIs by breaking down the interface into small reusable components. The virtual DOM is React also ensures that its performance efficient

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

What is the virtual DOM and why is it important in React

A

The virtual is a lightweight copy of the actual DOM. It ensures optimal rendering by comparing changes in the virtual DOM and applying only the necessary changes in the actual DOM, improving performance

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

Explain the concept of JSX in React.

A

JSX is a syntax like extension of Javascript used with React. It allows developers to write HTML like code to describe UI components. It is later transpiled to Javascript for execution in the browser.

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

What are React components. And how do you create them.

A

React components are reusable, self-contained pieces of UI that can be composed to create complex user interface. They can be created functionally or as a class-based component. Functional components are simple, concise, and stateless. Where as class based components are complex, state-full, and has life cycle methods. However, since the introduction of hooks functional components have become the preferred way for creating components since they allow functional to access functional components to access React features that where only available to class based components like state and side effects.

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

Explain the difference between state and props.

A

State and props are both used to manage data in React. Props are external inputs passed to a component by its parent, and they are immutable within the component and state are internal in the component and are mutable.

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

How do you handle forms in React.

A

Forms in React are typically controlled components, where form elements have their values controlled by the React state. This involves setting the attribute “value” to the corresponding state variable and handling the onchange event to update the state.

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

What is a React Router and how does it work.

A

React router is a library for handling routing and navigation in a React application. It enables the creation of single page applications with multiple views. React Router uses a component based approach to render different components based on the URL to provide a seamless user experience.

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

Describe the life cycle methods and why is it important in React

A

Class components in React have life cycle methods that are invoked at various stages of a components existence. Examples include componentDidMount, componentDidUnmount, component DidUpdate.

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

How does data flow in React.

A

The flow of data is unidirectional in React from parent to children. Changes in data is managed by lifting state up to a common ancestor, and communication between components is achieved through callback functions.

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

What are hooks, and why are we’re they introduced

A

Hooks are functions that provide functional components with React features that’s were previously only available in class-based components. Hooks provide a more concise way to manage state and side effects in a functional component

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

Explain the significance of the key attribute in React lists.

A

The key attribute is used to uniquely identify and track an item in a list during rendering. This helps React efficiently update the UI by recognizing which items have changed, been added or been removed in a list, preventing unnecessary re-rendering

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

How can you optimize performance in React.

A

Performance in React can be achieved by using techniques like code splitting, lazy loading, and Memoization and optimizing the rendering process by implementing shouldComponentUpdate, PureComponents and using production builds.

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

What is Redux, and when would you use it in a React Application

A

Redux is a state management library for Javascript applications. It is used in React applications when the state needs to be managed centrally and shared amongst components.

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

Describe the difference between controlled components and uncontrolled components

A

Controlled components in React have their state controlled by React. In form inputs, the key attribute corresponds to a state variable, and the onChange handler is used to update the state. Uncontrolled components have their state managed internally and are not controlled React state.

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

How would you do authentication in React.

A

Authentication in React us handled by using techniques like JWT, secure cookies, OAuth. Typically, you store tokens securely and make authenticates requests.

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

What is the purpose of the shouldComponentUpdate in React applications

A

The shouldComponentUpdate is used to optimize rendering performance in React applications by controlling when a component should re-render. It is called before the component renders and allows developers to control whether the component should render or not based on the changes in the state and prop.j

17
Q

Explain the concept of High Order Components in React

A

High Order components are functions functions that take components and return a new enhanced component. They are used for code reuse, logic abstraction, and adding additional features to a component. It does not update the original component but rather returns creates a new one with the added features.

18
Q

What is the role of context in React

A

Context is used to pass data through the component tree to components without having to pass props manually at every level. A common use case it to share authentication status or theme values amongst components without using props.

19
Q

How can you handle state management in a large React applications

A

State management in React applications is handled by state management libraries like Redux, Context API, and my personal favorite zustand. This libraries keeps the state centralized and organized, making it more manageable and avoiding props drilling

20
Q

Describe the difference between functional and class components in React.

A

Functional components are simple and concise and are usually used for presentation purposes. They are stateless and don’t have life cycle methods. Class components, on the other hand, can hold and manage state. They have life cycle methods and are used for more complex logic and functionalities. With the introduction of Hooks, functional components can handle state and side effects as well