React Mid

1 / 24

What is React.memo, and how can it be used to optimize functional components?

Select the correct answer

1

React.memo is a method for managing component state.

2

React.memo is used to fetch data from an API.

3

React.memo is a higher order component used to optimize functional components by preventing unnecessary re-renders.

4

React.memo is used to define component styles.

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

Select the correct answer

1

A Higher-Order Component (HOC) in React is a method for fetching data.

2

A Higher-Order Component (HOC) in React is a technique for styling components.

3

A Higher-Order Component (HOC) in React is a way to manage component state.

4

A Higher-Order Component (HOC) in React is a function that takes a component and returns a new component.

What is a React error boundary, and how can it be useful for handling errors in components?

Select the correct answer

1

A React error boundary is a component that catches JavaScript errors anywhere in their child component tree.

2

A React error boundary is a way to define component styles.

3

A React error boundary is a method for managing component state.

4

A React error boundary is used to fetch data from an API.

Why is it important to maintain immutability when updating state in React?

Select the correct answer

1

Maintaining immutability when updating state in React is important because it helps ensure predictable state changes and simplifies debugging.

2

Maintaining immutability when updating state in React is important because it allows direct manipulation of DOM elements.

3

Maintaining immutability when updating state in React is important because it enhances CSS performance.

4

Maintaining immutability when updating state in React is important because it simplifies HTML markup.

Why can hooks not be conditional in React?

Select the correct answer

1

Hooks cannot be conditional in React because they cannot access props.

2

Hooks cannot be conditional in React because they cannot be used inside loops.

3

Hooks cannot be conditional in React because they rely on a consistent order of execution.

4

Hooks cannot be conditional in React because they cannot handle asynchronous code.

What is the difference between controlled vs. uncontrolled components in React?

Select the correct answer

1

Controlled components in React have their state controlled by React, while uncontrolled components have their state controlled by the DOM.

2

Controlled components in React can only be used in class components.

3

Uncontrolled components in React are used for managing global state.

4

Controlled components in React are used for handling side effects.

What is a pure function in React?

Select the correct answer

1

A pure function in React is a function that returns the same output for the same input without side effects.

2

A pure function in React is a function that can mutate state directly.

3

A pure function in React is a function that fetches data.

4

A pure function in React is a function that makes API calls.

What are forward refs?

Select the correct answer

1

Forward refs in React are used to manage component state.

2

Forward refs in React are used to fetch data from an API.

3

Forward refs in React are used to pass refs to child components.

4

Forward refs in React are used to handle side effects.

What are the two primary ways of creating components in React?

Select the correct answer

1

The two primary ways of creating components in React are CSS components and HTML components.

2

The two primary ways of creating components in React are server components and client components.

3

The two primary ways of creating components in React are functional components and class components.

4

The two primary ways of creating components in React are state components and stateless components.

What are the purpose of keys in React lists?

Select the correct answer

1

Keys in React lists help identify which items have changed, are added, or removed.

2

Keys in React lists are used to style the list items.

3

Keys in React lists are used to fetch data for the list items.

4

Keys in React lists are used to create event handlers for the list items.

Can web browsers read JSX directly?

Select the correct answer

1

No, web browsers cannot read JSX directly; it needs to be transpiled to JavaScript.

2

Yes, web browsers can read JSX directly without any transpilation.

3

Only some web browsers can read JSX directly.

4

Web browsers can read JSX if it is included in a script tag.

What does reconciliation mean in React?

Select the correct answer

1

Reconciliation in React is the process of updating the DOM to match the virtual DOM.

2

Reconciliation in React is the process of managing component states.

3

Reconciliation in React is the process of fetching data from APIs.

4

Reconciliation in React is the process of defining component styles.

What are React Fragments?

Select the correct answer

1

React Fragments are a method for managing state in React.

2

React Fragments are used to define CSS styles in React.

3

React Fragments are a way to handle side effects in React.

4

React Fragments let you group multiple elements without adding extra nodes to the DOM.

What is the virtual DOM?

Select the correct answer

1

The virtual DOM is a database for storing component states.

2

The virtual DOM is a tool for managing API requests.

3

The virtual DOM is a lightweight copy of the actual DOM that React uses to optimize updates.

4

The virtual DOM is a CSS framework for styling components.

What is NextJS and major features of it?

Select the correct answer

1

NextJS is a React framework for server-side rendering and static site generation.

2

NextJS is a CSS framework for styling React applications.

3

NextJS is a database management system for React applications.

4

NextJS is a testing library for React applications.

What are lifecycle methods?

Select the correct answer

1

Lifecycle methods are special methods in React components that are called at different stages of a component's life.

2

Lifecycle methods are used to style React components.

3

Lifecycle methods are used to fetch data in React components.

4

Lifecycle methods are used to define routes in React components.

What does unmounted mean in React?

Select the correct answer

1

Unmounted in React means the component is initialized but not rendered.

2

Unmounted in React means the component has been removed from the DOM.

3

Unmounted in React means the component is ready to receive props.

4

Unmounted in React means the component has been rendered to the DOM.

What does mounted mean in React?

Select the correct answer

1

Mounted in React means the component is initialized but not rendered.

2

Mounted in React means the component has been removed from the DOM.

3

Mounted in React means the component has been rendered to the DOM.

4

Mounted in React means the component is ready to receive props.

What does lifting state up mean in React?

Select the correct answer

1

Lifting state up means moving state to the global scope.

2

Lifting state up means moving state to a child component.

3

Lifting state up means moving state to a common ancestor component.

4

Lifting state up means moving state to a sibling component.

Name tools that can be used to test React apps?

Select the correct answer

1

Tools like Webpack and Babel can be used to test React apps.

2

Tools like MongoDB and PostgreSQL can be used to test React apps.

3

Tools like Redux and MobX can be used to test React apps.

4

Tools like Jest, Enzyme, and React Testing Library can be used to test React apps.

What are synthetic events in React?

Select the correct answer

1

Synthetic events in React are cross-browser wrappers around native events.

2

Synthetic events in React are a way to manage component state.

3

Synthetic events in React are a method for fetching data.

4

Synthetic events in React are a way to define CSS styles.

How do you create an event in React?

Select the correct answer

1

You create an event in React by defining CSS styles.

2

You create an event in React by writing HTML templates.

3

You create an event in React by using the useState hook.

4

You create an event in React by defining an event handler function and attaching it to an element.

What is an event in React?

Select the correct answer

1

An event in React is an object that represents a user action.

2

An event in React is a component lifecycle method.

3

An event in React is a method for managing state.

4

An event in React is a way to define component styles.

How to loop inside JSX?

Select the correct answer

1

You can loop inside JSX using the useState hook.

2

You can loop inside JSX using CSS styles.

3

You can loop inside JSX using HTML templates.

4

You can loop inside JSX using the map() function.