Skip to main content

Posts

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...

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...

How to Write Effective Prompts: A Universal Framework for Any AI Model

  Introduction In the age of generative AI, the ability to write a good prompt is the new literacy. Whether you are using ChatGPT, Claude, Gemini, or a model that hasn’t been invented yet, the underlying logic remains the same. Many beginners fall into the trap of "Garbage In, Garbage Out." They type a vague sentence, get a mediocre result, and assume the AI isn't smart enough. The reality is often different: the AI is capable, but the instructions were unclear. To master AI, you don't need to learn code. You need to learn Prompt Engineering . This guide will teach you a universal framework— The R.T.C.F. Method —that works on every major language model available today. The Problem with Vague Prompts Let’s start with a classic mistake. The Prompt: "Write an email about our new product." This is a weak prompt because it lacks variables. The AI has to guess the tone, the recipient, the length, and the key selling points. The result will likely be generic, robo...

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...

How React JS Works: Components, State, and Props Explained Simply

Introduction After understanding why developers use React JS , the next important step is learning how React actually works . Many beginners feel confused by terms like components , state , and props — even though these are the core concepts of React. In this article, we’ll break down how React JS works , using simple explanations and clear examples , without unnecessary complexity. How React JS Thinks About the UI Traditional websites update the page by reloading everything. React takes a different approach. React treats the user interface as: A collection of small, reusable pieces called components Each component controls: What is displayed How it behaves When it updates When data changes, React automatically updates the affected parts of the UI. What Are Components in React? A component is a reusable piece of the interface. Examples of components: Button Navbar Card Form Footer Instead of writing HTML repeatedly, React lets you build o...

Why Use React JS? Pros, Cons, and Real Use Cases

  Introduction React JS has been one of the most popular JavaScript libraries for building user interfaces for many years. From small personal projects to large-scale applications, React is widely adopted by developers and companies around the world. But why do so many people choose React JS? Is it always the right choice? In this article, we’ll explore why React JS is used , its advantages , limitations , and real-world use cases to help you understand when React makes sense — and when it doesn’t. What Is React JS? React JS is a JavaScript library developed by Facebook (now Meta) for building user interfaces , especially single-page applications (SPAs) . Instead of updating the entire page, React updates only the parts of the UI that change, making applications faster and more interactive. React focuses on the view layer , meaning it handles how things look and behave in the browser. Why Developers Choose React JS React became popular because it solves many problems ...