To submit the task answer the questions.
1. Which of the following statements about the useCallback hook are true?

useCallback is useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary re-renders.

useCallback's returned function always has the same reference, so React won't re-render the component for the same function.

useCallback is used to memorize the initial state.

You must specify all values that the callback depends on in the useCallback dependency array.
2. What is the purpose of the useEffect hook in React?

useEffect hook is used to mimic lifecycle events from the class components.

useEffect hook is used to generate a component's initial state.

useEffect hook is used to handle form submissions in React.

useEffect hook is used to to handle side effects to various events.
3. Which of the following statements about the useEffect hook are true?

The useEffect hook in functional components provides capabilities similar to the componentDidMount, componentDidUpdate and componentWillUnmount lifecycle methods in class components.

The useEffect hook returns JSX elements.

The second argument to useEffect is an array of variables that, when changed, will cause the effect to rerun.

useEffect hook is used to perform side effects in function components.
4. Which of the following statements about the useReducer hook are true?

useReducer cannot handle the local state; it is only for global state.

useReducer is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one.

useReducer can delete the current state and restore it to an initial state.

useReducer hook dispatches actions to the reducer function to update the state.
5. What is the main purpose of the useRef hook in React?

useRef is used to create and manage state in functional components.

useRef is used to create a mutable reference object whose .current property is initialized with the passed argument.

useRef is used to handle lifecycle events in functional components.

useRef is used to pass props to child components in the component hierarchy.
6. What is the purpose of the useState hook in React?

useState manipulates the Document Object Model.

useState handles asynchronous requests.

useState optimizes component rendering.

useState provides a way to add local state to a functional component.
7. What are the main advantages of using React Hooks?

React Hooks simplify code by enabling complex operations with less code.

React Hooks work within the render method in a functional component.

React Hooks allow functional components to manage their own state, side effects, context, and more.

React Hooks make it easier to integrate with external libraries.
8. What is the main purpose of the useReducer hook in React?

useReducer is used to handle asynchronous API data fetching.

useReducer is used to bypass prop-drilling by providing state to components deep in the component tree.

useReducer is used as an alternative to useState that allows for more complex state logic.

useReducer is used to avoid the re-render of a component when state changes.
9. Which of these are the fundamental hooks in React?

useState, useEffect, useContext

useData, useStructure, useTrigger

useModel, useController, useView

useAction, useMutation, useRender
10. Which of the following statements about the useState hook are correct?

useState returns an array with two elements: the current state value and a function to update it.

useState can accept a function as an argument.

useState triggers re-rendering of a component whenever the state changes.

useState can only be used inside the render method of a class component.
11. Which of the following is a common mistake in using hooks in React?

Using hooks inside loops, nested functions, or conditions.

Calling hooks at the top-level of functional components.

Using a large number of hooks in a single component.

Using hooks within React components instead of regular JavaScript functions.
12. Which of the following statements about the useRef hook are true?

useRef returns a mutable ref object whose .current property is initialized with the passed argument and persists for the full lifetime of the component.

The useRef hook is used when you want to access DOM nodes directly within functional components.

React will ensure that any useRef object assigned to a property will persist for the lifetime of the DOM element.

A ref created with useRef will trigger render cycle if it's value is changed.
13. What is a key feature of custom hooks in React?

They allow you to manipulate the Document Object Model directly within your functional components.

They provide a way to use lifecycle methods within class components.

They are an advanced feature of React that allow you to break component logic into smaller reusable functions.

They speed up render times by reducing the amount of code that React needs to evaluate.
14. What is the purpose of hooks in React?

React Hooks make it easier to work with the document object model.

React Hooks allow using state and lifecycle features in functional components.

React Hooks are used to handle asynchronous requests in React.

React Hooks reduce JSX repetition and make code shorter.
15. What is the purpose of the useContext hook in React?

useContext helps to handle side effects within function components.

useContext allows to make some value available to a part of the component tree without prop drilling.

useContext is used for re-rendering a component when its state changes.

useContext is used to optimize performance by preventing unnecessary re-rendering of components.
16. What is the main purpose of the useMemo hook in React?

useMemo is used to handle asynchronous API data fetching.

useMemo is used to bypass prop-drilling by providing state to components deep in the component tree.

useMemo is used as an alternative to useState that allows for more complex state logic.

useMemo returns a memoized value, only re-computing the memoized value when one of its dependencies has changed.
17. Which of the following are common mistakes developers make when using hooks in React?

Using hooks only in functional components, never in class components.

Calling hooks inside of loops or conditions.

Implementing the useEffect hook without providing a second argument.

Including all variables used by the effect function into the dependency array of useEffect.
18. Given this common pitfall when using React hooks: Not including dependencies in useEffect. How can you avoid this mistake?

Ignore the warning messages about missing dependencies.

Make sure to include all dependencies of your useEffect in the dependency array.

Use only built-in React hooks and avoid custom hooks.

Use hooks only in class components instead of functional components.
19. Which of the following statements about the useContext hook are true?

A large number of useContext hooks in a single component can degrade performance.

useContext hook makes it easy to pass data at different levels of the component tree without needing to pass props at every level.

useContext hook receives a context object and returns the current context value for that context.

useContext hook can be used in class components.
20. Which of the following statements about the useMemo hook are true?

You don't need to pass an array of dependencies to useMemo because it automatically detects changes.

useMemo can be used to replace all effects (lifecycles) in functional components.

useMemo returns a memoized value, helping performance optimization by only re-computing expensive functions when necessary.

The list of dependencies of useMemo must include all the variables, values and props used inside the function passed to useMemo.