I have a React component
export default class Archive extends React.Component {
...
}
componentDidMount
and onClick
With React Functional way
import React, { useEffect } from "react";
import ReactDOM from "react-dom";
import Button from "@material-ui/core/Button";
const App = () => {
const saySomething = (something) => {
console.log(something);
};
useEffect(() => {
saySomething("from useEffect");
});
const handleClick = (e) => {
saySomething("element clicked");
};
return (
);
};
ReactDOM.render( , document.querySelector("#app"));
https://codesandbox.io/s/currying-meadow-gm9g0