-
What is the purpose of the children prop in a React component?
- a) It represents the child components rendered inside the component (Correct Answer)
- b) It defines the default content of the component
- c) It passes data from parent to child components
- d) It defines the structure of the component
-
Which of the following statements about React components is true?
- a) Functional components can have lifecycle methods
- b) Class components can return multiple elements without using a wrapper element
- c) Functional components are simpler and easier to read and write compared to class components (Correct Answer)
- d) All of the above
-
What is the primary role of ReactDOM in a React application?
- a) To handle routing and navigation
- b) To manage global application state
- c) To render React components into the DOM (Correct Answer)
- d) To handle server-side rendering
-
In React, which hook is used to perform side effects after every render?
- a) useEffect (Correct Answer)
- b) useState
- c) useMemo
- d) useContext
-
What is the purpose of the useMemo hook in React?
- a) To memoize the result of a function so that it is only recomputed when its dependencies change (Correct Answer)
- b) To manage component state
- c) To perform side effects in functional components
- d) To subscribe to context changes
-
In React, what does it mean to lift state up?
- a) It refers to managing state at the lowest level of the component tree
- b) It refers to passing state from child to parent components
- c) It refers to moving state to a common ancestor component to share it between sibling components (Correct Answer)
- d) It refers to removing state from a component
-
What is the purpose of the defaultProps property in a React component?
- a) To define default values for props (Correct Answer)
- b) To set the initial state of a component
- c) To define the default styling for a component
- d) To handle default event behavior
-
In React, what is the purpose of the key prop when rendering a list of components?
- a) It defines the style of each list item
- b) It helps React identify which items have changed, are added, or are removed in the list (Correct Answer)
- c) It sets the initial state of each list item
- d) It specifies the order of the list items
-
What is the purpose of the children prop in a React component?
- a) It represents the child components rendered inside the component (Correct Answer)
- b) It defines the default content of the component
- c) It passes data from parent to child components
- d) It defines the structure of the component
-
Which of the following statements about React components is true?
- a) Functional components can have lifecycle methods
- b) Class components can return multiple elements without using a wrapper element
- c) Functional components are simpler and easier to read and write compared to class components (Correct Answer)
- d) All of the above
Comments