cover-img

React Js component life cycle

react js, componentDidMount(), componentDidUpdate(), componentWillUnmount(), useEffect()

30 September, 2022

1

1

0

img

life cycle

selesai belajar kita hapus aja nodemodules karena besarnya filenya, gampang nanti kita install ulang aja lagi. kalau mau kirim ke github kita buatkan .gitignore node_modules
selanjutnya kita but index.html
img

localhost:3000

selanjutnya kita akan melanjutkan code di App.jsx
buat component dengan class, untuk melihat life cycle lebih jelas dan kelihatan, biasanya kan component menggunakan function
img
sekarang kita akan menambahkan function tambah otomatis,
img

berhasil menjalankan fungsi tombol

untuk fetching data di panggil di lifecycle mounting
img
will mount destroy belum bisa dijalankan
img

setelah 3 detik button dihapus

berhasil ya life cyle component react, lahir, berkembang, mati. selanjutnya kita akan juga melhat perbedaan ketika menggunakan functional compoent MyButton2.jsx
install theme onedarkpro extension vs code
img

awal refresh

img

setelah 3 detik, dan button berfungsi

selanutnya kita akan menambah did mountnya menggunakan useEffect merupakan sebuah hook react
img

component function

cuman ini tidak akan jalan kita hapus ini dulu
img

berhasil menjalankan component will un mount

Terimkasih
Belajar :
Git bash
pnpm (package manager)
react react-dom react-scripts
component class
componentDidMount()
componentDidUpdate()
componentWillUnmount()
component function
useState
useEffect
setTimeout
conditional rendering
source :

1

1

0

Andi Ismail
Love Programing

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2025. Showcase Creators Inc. All rights reserved.