alternative for componentdidmount

JavaScript
import React, { useEffect } from 'react'const SampleComponent = () => {  useEffect(() => {    // code to run on component mount  }, [])return (<div>foo</div>)}export SampleComponent
Source

Also in JavaScript: