React Fundamentals

Description: React Fundamentals Quiz
Number of Questions: 15
Created by:
Tags: react javascript front-end development
Attempted 0/15 Correct 0 Score 0

What is React?

  1. A JavaScript library for building user interfaces

  2. A programming language for web development

  3. A framework for building mobile applications

  4. A tool for creating 3D graphics


Correct Option: A
Explanation:

React is a JavaScript library that is used for building user interfaces. It is declarative, efficient, and flexible.

What is the main concept behind React?

  1. Virtual DOM

  2. Component-based architecture

  3. Declarative programming

  4. All of the above


Correct Option: D
Explanation:

React is based on the concept of virtual DOM, component-based architecture, and declarative programming.

What is the purpose of the virtual DOM in React?

  1. To improve performance

  2. To make the code more readable

  3. To make the code more maintainable

  4. To make the code more portable


Correct Option: A
Explanation:

The virtual DOM is used in React to improve performance. It is a lightweight representation of the real DOM, which allows React to efficiently update the UI.

What is a component in React?

  1. A reusable piece of code that renders a UI

  2. A function that returns a UI

  3. A class that defines a UI

  4. All of the above


Correct Option: D
Explanation:

In React, a component can be a reusable piece of code that renders a UI, a function that returns a UI, or a class that defines a UI.

What is the difference between a class component and a functional component in React?

  1. Class components use state and lifecycle methods, while functional components do not

  2. Class components are more performant than functional components

  3. Functional components are more reusable than class components

  4. Functional components are easier to write than class components


Correct Option: A
Explanation:

The main difference between a class component and a functional component in React is that class components use state and lifecycle methods, while functional components do not.

What is the purpose of props in React?

  1. To pass data from a parent component to a child component

  2. To pass data from a child component to a parent component

  3. To share data between components

  4. To store data in a component


Correct Option: A
Explanation:

Props are used in React to pass data from a parent component to a child component.

What is the purpose of state in React?

  1. To store data that can change over time

  2. To store data that is passed from a parent component

  3. To share data between components

  4. To store data in a component


Correct Option: A
Explanation:

State is used in React to store data that can change over time.

What is the difference between a controlled component and an uncontrolled component in React?

  1. Controlled components are updated by the state of the component, while uncontrolled components are updated by the user

  2. Controlled components are more performant than uncontrolled components

  3. Uncontrolled components are more reusable than controlled components

  4. Uncontrolled components are easier to write than controlled components


Correct Option: A
Explanation:

The main difference between a controlled component and an uncontrolled component in React is that controlled components are updated by the state of the component, while uncontrolled components are updated by the user.

What is the purpose of a key in React?

  1. To identify each item in a list

  2. To improve performance

  3. To make the code more readable

  4. To make the code more maintainable


Correct Option: A
Explanation:

Keys are used in React to identify each item in a list. This is important for performance and for making the code more readable and maintainable.

What is the purpose of a context in React?

  1. To share data between components

  2. To pass data from a parent component to a child component

  3. To store data in a component

  4. To improve performance


Correct Option: A
Explanation:

Contexts are used in React to share data between components. This is useful for sharing data that is needed by multiple components, such as the current user or the current language.

What is the purpose of a hook in React?

  1. To add functionality to a component

  2. To improve performance

  3. To make the code more readable

  4. To make the code more maintainable


Correct Option: A
Explanation:

Hooks are used in React to add functionality to a component. This can include things like adding state, adding event handlers, or adding lifecycle methods.

What is the difference between a class hook and a function hook in React?

  1. Class hooks are used in class components, while function hooks are used in functional components

  2. Class hooks are more performant than function hooks

  3. Function hooks are more reusable than class hooks

  4. Function hooks are easier to write than class hooks


Correct Option: A
Explanation:

The main difference between a class hook and a function hook in React is that class hooks are used in class components, while function hooks are used in functional components.

What is the purpose of a reducer in React?

  1. To update the state of a component

  2. To pass data from a parent component to a child component

  3. To share data between components

  4. To improve performance


Correct Option: A
Explanation:

Reducers are used in React to update the state of a component. This is done by passing the current state and an action to the reducer, which then returns the new state.

What is the difference between a synchronous and an asynchronous action in React?

  1. Synchronous actions are executed immediately, while asynchronous actions are executed after a delay

  2. Synchronous actions are more performant than asynchronous actions

  3. Asynchronous actions are more reusable than synchronous actions

  4. Asynchronous actions are easier to write than synchronous actions


Correct Option: A
Explanation:

The main difference between a synchronous and an asynchronous action in React is that synchronous actions are executed immediately, while asynchronous actions are executed after a delay.

What is the purpose of a middleware in React?

  1. To intercept and modify actions before they reach the reducer

  2. To update the state of a component

  3. To pass data from a parent component to a child component

  4. To share data between components


Correct Option: A
Explanation:

Middlewares are used in React to intercept and modify actions before they reach the reducer. This can be useful for logging actions, adding additional data to actions, or handling errors.

- Hide questions