Quiz on REACT Library

1) What does JSX stand for in React?

a) JavaScript XML

b) JSON Extensible

c) JavaScript Extension

d) JavaScript XHR

Answer: a) JavaScript XML

2) In React, what function is used to change the state and re-render the component?

a) setState()

b) modifyState()

c) changeState()

d) updateState()

Answer: a) setState()

3) Which lifecycle method is invoked immediately after a component is inserted into the DOM?

a) componentDidMount()

b) componentWillMount()

c) componentDidUpdate()

d) componentWillUpdate()

Answer: a) componentDidMount()

4) What is the purpose of React Router?

a) State management in React

b) Routing in React applications

c) Animation effects in React components

d) Component styling in React

Answer: b) Routing in React applications

5) What is the tool used for bundling React applications?

a) Grunt

b) Gulp

c) Webpack

d) Parcel

Answer: c) Webpack

6) Which method is used to prevent unnecessary re-renders in React?

a) shouldComponentUpdate()

b) componentWillReceiveProps()

c) componentDidUpdate()

d) componentWillUnmount()

Answer: a) shouldComponentUpdate()

7) What does the useState hook do in React?

a) Adds state to functional components

b) Handles side effects in React components

c) Manages context in React

d) Creates reusable components

Answer: a) Adds state to functional components

8) Which React feature is used for passing data down to a component's children?

a) props

b) state

c) context

d) refs

Answer: a) props

9) What is the purpose of keys in React when rendering a list of elements?

a) They identify elements in the DOM

b) They provide styling information

c) They handle event propagation

d) They help React identify each element uniquely during updates

Answer: d) They help React identify each element uniquely during updates

10) Which method is used to perform side effects in React functional components?

a) componentDidMount()

b) useEffect()

c) componentWillMount()

d) componentWillUpdate()

Answer: b) useEffect()

11) What is the main benefit of using PropTypes in React?

a) Improved performance

b) Type checking for component props

c) Enhanced debugging capabilities

d) Simplified state management

Answer: b) Type checking for component props

12) What is the purpose of React Fragments?

a) They are used to create virtual DOM elements

b) They improve performance in React applications

c) They allow grouping of elements without adding extra nodes to the DOM

d) They handle events in React components

Answer: c) They allow grouping of elements without adding extra nodes to the DOM

13) What is the role of ReactDOM in React?

a) Manages component hierarchy

b) Renders React components in the DOM

c) Handles component state

d) Optimizes React application performance

Answer: b) Renders React components in the DOM

14) Which method is used to update the state based on the previous state in React?

a) modifyState()

b) setState()

c) updateState()

d) setStateWithPrevious()

Answer: b) setState()

15) What does Redux provide in React applications?

a) Local component state management

b) Server-side rendering

c) A predictable state container

d) Routing functionality

Answer: c) A predictable state container

Explore Categories

JAVA

PYTHON

BOOTSTRAP

JAVASCRIPT

PHP

REACT

CSS

C & C++

HOMEPAGE