REACT interview questions

  • What is “prop drilling” and how to prevent it
    • pass the state as “props” through each nested component
    • UseContext hook
  • Can you use hooks with class?
    • No
  • What is the difference between functional and class based components?

    • A functional component is just a plain JavaScript function that returns JSX. A class component is a JavaScript class that extends React.Component which has a render method.
  • Which type of component can access lifecyle events?
    • Class component have access to several other build-in methods.  These include component lifecycle methods, such as:

      • componentDidMount
      • componentDidUpdate
      • componentWillUnmount

      Functional components do not have access to these lifecycle methods.