Online Exam Quiz

questionQuestion  1 to 30

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

What is a portal in React?

  • A way to render children into a DOM node outside the parent component
  • A way to handle events
  • A way to manage state
  • A way to fetch data
Mark for review

How do you pass data to a child component?

  • Using state
  • Using props
  • Using events
  • Using functions
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

How do you connect a React component to the Redux store?

  • Using connect
  • Using useState
  • Using useEffect
  • Using useContext
Mark for review

How can you prevent a component from rendering in React?

  • By setting the 'visible' attribute to false
  • By returning null from the render method
  • By using the 'shouldComponentUpdate' method
  • By removing the component from the component tree
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

What is the purpose of middleware in Redux?

  • To handle asynchronous actions
  • To handle synchronous actions
  • To fetch data
  • To manage state
Mark for review

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

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

What does the useEffect hook do?

  • Manages state
  • Fetches data
  • Performs side effects in components
  • Defines components
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

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

  • To handle component errors
  • To perform layout effects in function components
  • To update the component's state
  • To memoize expensive calculations
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 do you handle side effects in a functional component?

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

What is the purpose of render props in React?

  • To share logic between components
  • To manage state
  • To handle side effects
  • To fetch data
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 state in React?

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

How can you optimize performance in a React application?

  • Using shouldComponentUpdate
  • Using componentDidUpdate
  • Using componentWillMount
  • Using componentDidCatch
Mark for review

Which method is used to render elements to the DOM in React?

  • ReactDOM.render()
  • React.render()
  • ReactDOM.mount()
  • React.mount
Mark for review

How do you unmount a component in React?

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

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

What is the purpose of useCallback hook?

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

How do you implement code splitting in React?

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

What is the purpose of memo in React?

  • To memoize functions
  • To prevent unnecessary re-renders
  • To handle state
  • To fetch data
Mark for review

What is the purpose of ErrorBoundary in React?

  • To catch JavaScript errors in components
  • To manage state
  • To handle routing
  • To fetch data
Mark for review

Which lifecycle method is invoked immediately after updating occurs in React?

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

How do you update state in a functional component?

  • Using setState
  • Using this.state
  • Using this.setState
  • Using useState
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

Which of the following is NOT a built-in Hook in React?

  • useCallback
  • useMemo
  • useState
  • useComponent
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