MCQ

React MCQs – Multiple Choice Questions and Answers – Part 3

Multiple choice questions and answers (MCQs) on React to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as UI, DOM, services, JSX, and more. This quiz will easily prepare anyone to pass their online test.
 

1. As soon as the state of the React component is modified, the component _______

A Does nothing, you have to call the render method to make the component

B restore the component

C recreated from scratch

D None of the above

B
As soon as the state is updated, the component is restored.

 

 

2. The React method getDerivedSateFromProps(props , state) is called when ____

A The component is created for the first time

B The state of the component is updated

C Both A and B are true.

D None of the above

C
getDerivedSateFromProps(props, state) is called in both cases, when the component is created and when the component is updated

 

 
 

3. The componentDidMount method is called when ____

A The component is created for the first time

B The state of the component is updated

C Both A and B are true.

D None of the above

A
componentDidMount is called when the component is created.

 

 

4. Which of the following APIs is a must-have for every ReactJS component?

A getInitialState

B render

C renderComponent

D None of the above

C

 

 

5. What are the advantages of React JS?

A React can be used on both the client and server sides.

B Using React increases readability and facilitates maintainability. Components, data models improve readability and thus facilitate the management of larger applications.

C React can be used with any other framework (Backbone.js, Angular.js) because it is only a View layer.

D All the answers are true

D

 

 

6. What is the purpose of the second argument of setState?

A To call any code after the setState operation is complete

B To completely replace the state instead of the default action

C To access the previous state before the setState operation

D None of the above

A

 

 
 

7. Which function can be used to change the state of a React component?

A this.State = {}

B this.setState

C this.changeState

D None of the above

B

 

 

8. What happens if you render an input element with disabled = {false}

A It will be rendered as enabled

B It will be rendered as disabled

C It will not be rendered at all

D None of the above

A

 

 

9. When is it recommended to pass this.setState as a function instead of an object?

A When the new state should completely replace the old state

B When the new state depends on the old state

C When the new state does not depend on the old state

D None of the above

B

 

 
 

10. What is the declarative way to make a dynamic list of components based on the values of an array.

A Use the reduce array method

B With a for/while loop

C Use the component <Each />

D Use the Array.map() method

D

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *