Skip to main content

Posts

Showing posts with the label React JS

Tutorial NextJS - Day 2

Hari 2 – Navigasi, Layout, & Dynamic Routing Setelah berhasil melakukan instalasi dan membuat halaman pertama di Hari 1 , pada Hari 2 ini kita akan membuat website menjadi lebih hidup. Kita akan belajar cara membuat menu navigasi agar bisa pindah-pindah halaman, membuat tampilan menu yang konsisten (Layout), dan membuat halaman artikel yang pintar (Dynamic Routing). Tutorial ini tetap menggunakan Windows + VS Code dan melanjutan project nextjs-basic dari hari sebelumnya. 1. Navigasi Antar Halaman ( <Link> ) Di HTML biasa, kita menggunakan tag <a> untuk berpindah halaman. Namun, di Next.js kita menggunakan komponen khusus bernama <Link> . Kenapa harus pakai <Link> ? Jika pakai <a> , layar akan berkedip (loading ulang) setiap pindah halaman. Dengan <Link> , perpindahan halaman terjadi instan tanpa refresh. 1.1 Edit Halaman Home Kita akan menambahkan tombol untuk pergi ke halaman About. Buka file src/app/page.tsx , lalu ganti isinya dengan kod...

React Build vs Development Mode: What’s the Difference?

Introduction Many React developers are surprised when their app works perfectly during development — but behaves differently after deployment. Features break, routing fails, environment variables disappear, or performance changes dramatically. Most of these issues come from not understanding the difference between React’s development mode and production (build) mode . In this article, we’ll explain: What development mode really does What changes in production builds Why bugs appear only after deployment How to avoid common build-related mistakes What Is Development Mode in React? Development mode is what you use when running commands like: npm start npm run dev In this mode, React prioritizes developer experience , not performance. Key Characteristics of Development Mode Detailed error messages Helpful warnings Hot reloading (instant updates) Slower performance (on purpose) Extra checks for unsafe patterns Development mode helps you find bugs e...

React Routing Explained (And Why It Breaks in Production)

  Introduction React routing often works perfectly during development — but suddenly breaks in production . Pages show a blank screen, return 404 errors, or fail when users refresh the browser. If you’ve ever asked: “Why does my React routing work locally but not after deployment?” This article will give you a clear, practical explanation . We’ll cover: How React routing actually works Why it breaks in production The most common mistakes How to fix routing issues correctly How React Routing Works React applications use client-side routing , most commonly with React Router . Instead of the server handling routes like: /about /contact /products React: Loads one HTML file ( index.html ) Uses JavaScript to switch views Updates the URL without reloading the page This is fast and smooth — but it creates problems if the server is not configured properly. Why Routing Works in Development During development: You usually run npm run dev or npm s...

Why Your React App Shows a Blank Page (And How to Fix It)

Introduction One of the most frustrating problems when working with React JS is opening your app and seeing… nothing . No error message. No UI. Just a blank page . This issue happens frequently, especially after deployment or routing changes. In this article, we’ll explain why React apps show a blank page , the most common causes , and how to fix them step by step . What a “Blank Page” Usually Means in React A blank page usually means: React failed to render the UI JavaScript error stopped execution Routing or build configuration is broken Most of the time, the issue is not React itself , but how the app is configured. 1. JavaScript Error in the Console The first thing you should always check is the browser console. How to Check Open the app Right click → Inspect Open the Console tab If you see a red error message, React stopped rendering. Common Examples Cannot read property of undefined Unexpected token Module not found Fix Read the...

More Common React JS Mistakes Developers Still Make (And How to Avoid Them)

  Introduction Even after learning the basics of React JS, many developers continue to make mistakes that hurt performance, readability, and scalability. These are not beginner-only errors — they often appear in real projects, especially when apps start to grow. In this article, we’ll look at common React JS mistakes developers still make , explain why they happen , and show better patterns to avoid long-term problems. 1. Re-Creating Functions on Every Render Many developers define functions directly inside components without realizing the impact. ❌ Common Pattern function App ( ) { const handleClick = ( ) => { console . log ( "clicked" ); }; return < Button onClick = {handleClick} />; } While this works, the function is re-created on every render . ✅ Better Approach (When Needed) const handleClick = useCallback ( () => { console . log ( "clicked" ); }, []); Why This Matters Causes unnecessary re-renders Affects per...

Common React JS Mistakes Beginners Make (And How to Fix Them)

Introduction React JS is powerful, but many beginners struggle not because React is hard — but because of common mistakes made early on . These mistakes can lead to confusing bugs, poor performance, and messy code that becomes difficult to maintain. In this article, we’ll cover the most common React JS mistakes beginners make , explain why they happen , and show how to fix them properly . If you’re learning React or recently started building projects, this guide will save you hours of frustration. 1. Modifying State Directly One of the most frequent beginner mistakes is changing state directly instead of using the state updater function. ❌ Wrong Example count = count + 1 ; This does not trigger a re-render. ✅ Correct Way setCount (count + 1 ); Why This Matters React relies on state updates to know when to re-render . Direct mutation breaks that mechanism and causes unpredictable UI behavior. 2. Using State When It’s Not Needed Beginners often store everything in state...