๐ฏ Tujuan Pembelajaran
- Memahami fungsi folder public, src, node_modules
- Memahami alur kerja React
- Memahami hubungan
index.htmldanindex.jssertapp.js
๐ 1. Struktur Dasar Project React
project/
โโโ node_modules/
โโโ public/
โ โโโ index.html
โโโ src/
โ โโโ index.js
โ โโโ App.js
โโโ package.json
๐ง 2. Fungsi Setiap Bagian
๐ฆ node_modules/
Tempat semua library disimpan (React, Bootstrap, dll).
๐ โGudang dependensiโ
๐ public/
File yang langsung dibaca browser tanpa diproses React.
index.html
๐ โHalaman utama (root)โ
โ๏ธ src/
Tempat menulis kode React.
๐ โOtak aplikasiโ
๐ package.json
Daftar library dan konfigurasi project.
๐ 3. Hubungan Antar File
index.html
โ
index.js
โ
App.js
โ
Komponen lain
๐ฌ 4. SIMULASI ALUR (Animasi Teks)
๐ข STEP 1 โ Browser buka website
๐ User membuka: http://localhost:3000
๐ Dibaca pertama: public/index.html
๐ก STEP 2 โ HTML ditemukan
<div id="root"></div>
Masih kosong ๐ถ
๐ต STEP 3 โ JavaScript dijalankan
React mulai berjalan dari src/index.js
๐ฃ STEP 4 โ React render
root.render(<App />);
๐ STEP 5 โ App.js dipanggil
<h1>Hello World</h1>
๐ด STEP 6 โ Tampil di layar
๐ฅ๏ธ Hello World muncul di browser
๐ฅ Ringkasan Alur
๐ Browser
โ
๐ index.html
โ
โ๏ธ index.js
โ
๐ฆ App.js
โ
๐ฅ๏ธ UI tampil
๐ฅ Analogi Sederhana
- index.html = layar TV ๐บ
- index.js = remote ๐ฎ
- App.js = channel ๐ก
โ ๏ธ Kesalahan Umum
- Mengira index.js dibuka pertama
- Menaruh semua file di public
- Bingung kenapa root kosong
๐ก Bonus Praktik
- Praktik 1, hapus isi
Lihat apa yang terjadi.<div id="root"></div> - Praktik 2, Ubah teks di App.js, Lihat perubahan realtime
- Praktik 3,
<button className="btn btn-primary">Klik</button>