1. What is React?

    React is a JavaScript library used for building user interfaces, especially single-page applications (SPAs). It allows developers to create reusable UI components.

    Key Points:

    One-line Summary:

    React is a JavaScript library for building fast, reusable, and dynamic user interfaces using components.

  2. Why use React?

    React is used to build fast, scalable, and maintainable user interfaces for modern web applications.

    Key Points:

    One-line Summary:

    React is used because it makes building dynamic, scalable, and high-performance UIs easier and more efficient.

  3. Virtual DOM

    Virtual DOM is a lightweight copy of the real DOM that React uses to improve performance. Instead of updating the real DOM directly, React first updates the Virtual DOM and then efficiently updates only the changed parts in the real DOM.

    Key Points:

    One-line Summary:

    Virtual DOM is a lightweight copy of the real DOM that helps React update the UI efficiently.

  4. Difference between state and props.

    Feature Props State
    Meaning Data passed from parent to child Data managed inside a component
    Mutability Immutable (cannot be changed) Mutable (can be changed using setState/useState)
    Controlled By Parent component The component itself
    Purpose Make components reusable Manage dynamic data

    Key Points:

    One-line Summary:

    Props are read-only data passed from parent, while state is internal data managed and updated within a component.

  5. What is JSX?

    JSX (JavaScript XML) is a syntax extension for JavaScript that allows writing HTML-like code inside JavaScript in React.

    Key Points:

    Example:

    const element = <h1>Hello Rohan</h1>;
    

    One-line Summary:

    JSX is a syntax that lets you write HTML-like code inside JavaScript for building React components.

  6. Functional vs class components

    Feature Functional Component Class Component
    Syntax Simple JavaScript function ES6 class
    State Uses Hooks (useState) Uses this.state
    Lifecycle Uses Hooks (useEffect) Uses lifecycle methods
    this keyword Not used Required
    Code Complexity Simple & shorter More verbose

    Key Points:

    One-line Summary:

    Functional components are simpler and use Hooks, while class components use classes and lifecycle methods.

  7. What is useState?

    useState is a React Hook that allows functional components to manage state.

    Key Points:

    Example:

    import { useState } from "react";
    
    function Counter() {
      const [count, setCount] = useState(0);
    
      return (
        <button onClick={() => setCount(count + 1)}>
          {count}
        </button>
      );
    }
    

    One-line Summary:

    useState is a React Hook used to add and manage state inside functional components.

  8. What is useEffect?

    useEffect is a React Hook used to handle side effects in functional components, like API calls, timers, or DOM updates.

    Key Points:

    Example:

    import { useEffect } from "react";
    
    useEffect(() => {
      console.log("Component mounted");
    
      return () => {
        console.log("Cleanup");
      };
    }, []);
    

    One-line Summary:

    useEffect is a Hook used to handle side effects and lifecycle behavior in functional components.

  9. Dependency array in useEffect

  10. What is controlled component?

  11. Uncontrolled component

  12. What is lifting state up?

  13. What is prop drilling?

  14. How to avoid prop drilling

  15. What is context API?

  16. What is useContext?

  17. What is reconciliation?

  18. What is key in list?

  19. Why keys are important?

  20. What is memo?