Online Exam Quiz

questionQuestion  1 to 30

How do you unmount a component in React?

  • Using componentWillUnmount
  • Using componentDidMount
  • Using useEffect
  • Using setState
Mark for review

How do you perform conditional rendering in React?

  • Using if statements
  • Using for loops
  • Using ternary operators
  • Using switch statements
Mark for review

What does JSX stand for in React.js?

  • JavaScript XML
  • JavaScript Extension
  • JavaScript XQuery
  • JavaScript External
Mark for review

What is the purpose of keys in React?

  • To identify elements uniquely
  • To set state
  • To define props
  • To handle events
Mark for review

In React, what is the purpose of the 'useReducer' Hook?

  • To handle component errors
  • To manage complex state logic
  • To define the initial state of a component
  • To perform side effects in function components
Mark for review

What is the purpose of PropTypes in React?

  • To specify the type of data expected in props
  • To define the initial state of a component
  • To manage component input
  • To handle component events
Mark for review

What is the purpose of the 'useCallback' Hook in React?

  • To memoize expensive calculations
  • To update the component's state
  • To handle component errors
  • To perform side effects in function components
Mark for review

What is the purpose of state in React?

  • To store props
  • To store component metadata
  • To manage component input
  • To manage component data that may change
Mark for review

What is the purpose of the 'key' prop in React?

  • It specifies the CSS class of an element
  • It provides a unique identifier for a component in an array
  • It defines the initial state of a component
  • It sets the default props of a component
Mark for review

What is the purpose of the 'useContext' Hook in React?

  • To update the component's state
  • To handle component errors
  • To access React context in function components
  • To perform side effects in function components
Mark for review

What is a component in React?

  • A function that returns JSX
  • A class that fetches data
  • A library for routing
  • A method for state management
Mark for review

How do you create a controlled component in React?

  • By using refs
  • By managing the component state
  • By setting the 'controlled' attribute
  • By using event listeners
Mark for review

What is the difference between props and state in React?

  • props are mutable, state is not
  • state is immutable, props are not
  • props are immutable, state is mutable
  • props are for functions, state is for classes
Mark for review

Which of the following Hooks can be used to subscribe to document title changes in React?

  • useEffect
  • useMemo
  • useContext
  • useDocumentTitle
Mark for review

In React, what is the purpose of the 'static getDerivedStateFromError' method?

  • To update the component's state based on errors
  • To initialize the component's state
  • To perform cleanup after an error occurs
  • To handle errors that occur during rendering
Mark for review

What is a pure component in React?

  • A component with no side effects
  • A component that only re-renders when its props change
  • A component that always re-renders
  • A component that fetches data
Mark for review

What is the purpose of useCallback hook?

  • To memoize functions
  • To memoize values
  • To handle side effects
  • To fetch data
Mark for review

Which method is called when a component is first added to the DOM?

  • componentDidMount()
  • componentWillMount()
  • componentWillUpdate()
  • componentDidUpdate
Mark for review

How can you prevent a component from re-rendering in React?

  • By using shouldComponentUpdate method
  • By returning false from the render method
  • By setting the 'shouldUpdate' attribute to false
  • By removing the component from the component tree
Mark for review

How do you pass data to a child component?

  • Using state
  • Using props
  • Using events
  • Using functions
Mark for review

In React, what is the purpose of the 'shouldComponentUpdate' method?

  • To determine if a component should be rendered
  • To define component lifecycle
  • To handle component events
  • To manage component input
Mark for review

What is the purpose of useRef hook?

  • To manage state
  • To create mutable references
  • To handle side effects
  • To define context
Mark for review

What function is used to change the state in React?

  • this.state()
  • this.setState()
  • this.changeState()
  • this.modifyState
Mark for review

Which of the following methods is called after the component is rendered in React?

  • componentWillMount()
  • omponentDidMount()
  • componentDidUpdate()
  • componentWillReceiveProps
Mark for review

In React, how can you conditionally render components?

  • Using if-else statements
  • Using switch statements
  • Using ternary operators
  • All of the above
Mark for review

How do you create a reference to a DOM element in React?

  • Using createRef
  • Using useState
  • Using useEffect
  • Using useReducer
Mark for review

In React, what is the purpose of the 'forwardRef' function?

  • To pass refs to child components
  • To create refs dynamically
  • To forward props to child components
  • To access the DOM node of a child component
Mark for review

How do you create a class component in React?

  • class MyComponent extends React.Component
  • const MyComponent = () => {}
  • function MyComponent() {}
  • React.createClass()
Mark for review

Which of the following statements about React Suspense is true?

  • It is used to handle errors in React components
  • It is used to suspend rendering while waiting for data to load
  • It is deprecated in the latest version of React
  • It is used to manage component state
Mark for review

How do you implement code splitting in React?

  • Using import()
  • Using require()
  • Using React.split()
  • Using React.lazy()
Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review