Skip to content

Instantly share code, notes, and snippets.

@robzlabz
Created January 7, 2021 06:18
Show Gist options
  • Save robzlabz/47f70079ad4a7eb201b2ebb53cd0e08a to your computer and use it in GitHub Desktop.
Save robzlabz/47f70079ad4a7eb201b2ebb53cd0e08a to your computer and use it in GitHub Desktop.
import React from "react";
// di functional component menggunakan useEffect dengan argumen kedua [] array kosong
const FunctionalComponent = () => {
React.useEffect(() => {
console.log("Aku Dijalankan");
}, []);
return <h1>Halo, Selamat Pagi</h1>;
};
// contoh class component
class ClassComponent extends React.Component {
componentDidMount() {
console.log("Aku Dijalankan");
}
render() {
return <h1>Halo, Selamat Pagi</h1>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment