Online Exam Quiz

questionQuestion  1 to 30

What is the purpose of useRef hook?

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

Which of the following is NOT a valid lifecycle method in React?

  • componentWillMount()
  • componentWillUpdate()
  • componentDidReceiveProps()
  • componentWillUnmount
Mark for review

What is the purpose of the 'strict mode' in React?

  • To enforce strict syntax rules
  • To provide a development-friendly environment
  • To optimize performance
  • To enable additional debugging checks
Mark for review

How do you create a custom Hook in React?

  • By extending the React.Component class
  • By using the 'createHook' function
  • By prefixing the function name with 'use'
  • By importing the 'CustomHook' module
Mark for review

How can you optimize performance in a React application?

  • Using shouldComponentUpdate
  • Using componentDidUpdate
  • Using componentWillMount
  • Using componentDidCatch
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

How can you optimize performance in React?

  • By using pure components
  • By minimizing the use of inline styles
  • By avoiding unnecessary re-renders
  • All of the above
Mark for review

Which method is used to handle lifecycle events in a class component?

  • componentDidMount
  • useEffect
  • render
  • setState
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

What is the purpose of useMemo hook?

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

In React.js, what is used to pass data to a component from outside?

  • Props
  • State
  • setState()
  • Component
Mark for review

How do you define default props in a component?

  • Using defaultProps
  • Using props
  • Using state
  • Using context
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

Which lifecycle method is called before a component is removed from the DOM?

  • componentWillUnmount()
  • componentDidUnmount()
  • componentWillUnmount()
  • componentDidUpdate
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

What is the purpose of ReactDOM?

  • To define components
  • To manage state
  • To render React components to the DOM
  • To create context
Mark for review

How do you pass data to a child component?

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

What is the purpose of the 'dangerouslySetInnerHTML' attribute in React?

  • To set the HTML content of a component
  • To define dangerous HTML code
  • To bypass React's XSS protection
  • To execute JavaScript code
Mark for review

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

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

What function is used to change the state in React?

  • this.state()
  • this.setState()
  • this.changeState()
  • this.modifyState
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

How do you handle forms with controlled components?

  • Using value and onChange props
  • Using defaultValue prop
  • Using setState
  • Using useEffect
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

How do you unmount a component in React?

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

What is the purpose of the 'defaultProps' property in React?

  • To define default values for props
  • To specify the default state of a component
  • To set the default event handlers
  • To define default CSS styles
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

Which of the following methods is used to perform side effects in React?

  • componentDidMount()
  • componentDidUpdate()
  • componentWillUnmount()
  • All of the above
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

How do you lazy load components in React?

  • Using React.lazy
  • Using useEffect
  • Using useContext
  • Using useState
Mark for review

What hook is used to manage state in a functional component?

  • useContext
  • useEffect
  • useReducer
  • useState
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