Share
Explore

20 exam questions with answers on REACT

20 exam questions with answers on REACT, REACT.js and REACT Native. TF, MCQ, Short Answer, Coding
True or False: React is a framework for building web applications.
Answer: False. React is a JavaScript library for building user interfaces.
What is React.js?
Answer: React.js is a JavaScript library developed by Facebook for building user interfaces.
What is JSX in React?
Answer: JSX is a syntax extension for JavaScript used in React to describe the UI components.
Which lifecycle method is called once the component is mounted on the DOM?
Answer: componentDidMount().
What is the virtual DOM in React?
Answer: The virtual DOM is a representation of the actual DOM in React that helps in efficient updates and rendering of the UI.
What is the purpose of state in React?
Answer: State is used for storing and managing the data of a component.
True or False: React Native is a framework for building web applications.
Answer: False. React Native is a framework for building mobile applications.
What is the purpose of the render() method in React?
Answer: The render() method is used to describe the UI of a component.
What is the purpose of props in React?
Answer: Props are used for passing data and methods from a parent component to a child component.
Which component lifecycle method is called before the component is unmounted from the DOM?
Answer: componentWillUnmount().
What is the purpose of the stateless functional component in React?
Answer: The purpose of a stateless functional component is to render the UI based on the props passed to it.
What is Redux in React?
Answer: Redux is a state management library used for managing the state of an entire application in React.
True or False: React components can only return a single child element.
Answer: True.
What is the difference between controlled and uncontrolled components in React?
Answer: Controlled components are those components whose data is controlled by React, while uncontrolled components are those whose data is controlled by the DOM.
What is the purpose of the setState() method in React?
Answer: The setState() method is used for updating the state of a component.
What is the purpose of the React Router in React?
Answer: The React Router is used for handling navigation and routing in a React application.
What is the purpose of the shouldComponentUpdate() method in React?
Answer: The shouldComponentUpdate() method is used for optimizing the rendering of a component by checking if the component needs to be re-rendered or not.
What is the purpose of the keys in React?
Answer: Keys are used for identifying and differentiating between the elements in a list in React.
What is the purpose of the PureComponent in React?
Answer: The PureComponent is a class component in React that implements the shouldComponentUpdate() method to automatically optimize rendering and prevent unnecessary updates.
Write a code snippet to create a simple React component that renders a "Hello, World!" message.
Answer:
javascriptCopy code
import React from 'react';

class HelloWorld extends React.Component {
render() {
return <h1>Hello, World!</h1>;
}
}

export default HelloW
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.