reactjs: how to define componentDidMount inside ES6 const?
<p>I have this react component that is not an ES6 <code>class</code>. It's a <code>const</code> like :</p>

<pre><code>import React from 'react';
import Dashboard from './components/Dashboard';

const Home = (props) =&gt; {

    const componentDidMount = () =&gt; {
        console.log('component mounted'); // not working
    }


    return &lt;Dashboard /&gt;;
}
</code></pre>

<p>Inside this const how do i define the <code>componentDidMount</code> function like i would do in a normal ES6 <code>class</code>? this is how i did it before.</p>

<pre><code>import React from 'react';
import Dashboard from './components/Dashboard';

class Dashboard extends React.Component {

    componentDidMount() {
        console.log('component mounted');
    }

    render() {
        return &lt;Dashboard /&gt;;
    }

}
</code></pre>