DEV Community

SATHISHKUMAR R
SATHISHKUMAR R

Posted on

What is Mounting in React?

Mounting is the first phase of a React component's lifecycle.
When a component is created and displayed on the screen for the first time, it is called Mounting.

  1. Mounting steps
  2. Component Function Runs – React executes the component.
  3. DOM Creation – React prepares the UI.
  4. DOM Update – React displays the UI on the screen.
  5. useEffect Runs – The effect runs after the component is displayed.

Example:

import React, { useEffect } from 'react';

function App() {

useEffect(() => {
    console.log("Component Mounted");
}, []);

return (
    <h1>Hello React!</h1>
);
Enter fullscreen mode Exit fullscreen mode

}

export default App;

Output:

Hello React!

Console:

Component Mounted

Top comments (0)