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 used to define component styles.

2

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

3

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

4

React.memo is a method for managing component state.

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

Select the correct answer

1

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

2

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

3

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

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 method for managing component state.

2

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

3

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

4

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

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 handle asynchronous code.

3

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

4

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

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

Select the correct answer

1

Uncontrolled components in React are used for managing global state.

2

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

3

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

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 makes API calls.

4

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

What are forward refs?

Select the correct answer

1

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

2

Forward refs in React are used to manage component state.

3

Forward refs in React are used to handle side effects.

4

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

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 functional components and class 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 CSS components and HTML 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

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

2

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

3

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

4

Only some web browsers can read JSX directly.

What does reconciliation mean in React?

Select the correct answer

1

Reconciliation in React is the process of defining component styles.

2

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

3

Reconciliation in React is the process of managing component states.

4

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

What are React Fragments?

Select the correct answer

1

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

2

React Fragments are a method for managing state in React.

3

React Fragments are used to define CSS styles 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 CSS framework for styling components.

3

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

4

The virtual DOM is a tool for managing API requests.

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 used to fetch data in React components.

2

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

3

Lifecycle methods are used to define routes in React components.

4

Lifecycle methods are used to style React components.

What does unmounted mean in React?

Select the correct answer

1

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

2

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

3

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

4

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

What does mounted mean in React?

Select the correct answer

1

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

2

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

3

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

4

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

What does lifting state up mean in React?

Select the correct answer

1

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

2

Lifting state up means moving state to a child component.

3

Lifting state up means moving state to a sibling component.

4

Lifting state up means moving state to the global scope.

Name tools that can be used to test React apps?

Select the correct answer

1

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

2

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

3

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

4

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

What are synthetic events in React?

Select the correct answer

1

Synthetic events in React are a method for fetching data.

2

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

3

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

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 an event handler function and attaching it to an element.

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 CSS styles.

What is an event in React?

Select the correct answer

1

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

2

An event in React is a method for managing state.

3

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

4

An event in React is a component lifecycle method.

How to loop inside JSX?

Select the correct answer

1

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

2

You can loop inside JSX using HTML templates.

3

You can loop inside JSX using the useState hook.

4

You can loop inside JSX using CSS styles.