Search code examples
javascriptreactjslifecycle

ComponentDidMount is not being called - very simple app


I used create-react-app to create this very simple app. ComponentDidMount is never invoked.

import React, { Component } from "react";

class App extends Component {
  ComponentDidMount() {
    console.log("MOUNTED");
  }

  render() {
    return (
      <div className="App">
        <h1>Hi Lol</h1>
      </div>
    );
  }
}

export default App;

Solution

  • Method names are case sensitive, so you should start with a lowercase: componentDidMount instead of ComponentDidMount.