Waktu ngoding React, gue sering banget nemuin pattern yang sama berulang-ulang di setiap project. Daripada nulis logic yang sama terus-terusan, mending bikin custom hooks aja yang bisa dipake berkali-kali. Nah, ini dia 5 custom hooks favorit gue yang worth it banget buat dicoba!
1. useDebounce - Delay Execution dengan Elegan
Masalahnya Apa?
Pernah bikin fitur search dengan auto-complete? Setiap kali user ngetik, langsung trigger API call. Boros banget! Bayangin user ngetik "javascript" - itu udah 10 API calls cuma buat 10 huruf doang.
Kodenya
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Nyimpen data ke localStorage itu ribet. Harus JSON.parse(), JSON.stringify(), plus handle error. Capek deh!
Pro tip: Delay qwndodnqwdnqwodnqwpiodn
Kesimpulan
Chunked file upload is not complicated in concept: split, send, reassemble. The complexity lies in handling the edge cases correctly: idempotency, ordering, failure states, and cleanup.
This implementation keeps responsibilities separated: the domain defines what a file is and what can go wrong, the application layer coordinates the chunking logic, infrastructure adapts to specific tools (PostgreSQL, local disk), and the HTTP layer translates between the application and HTTP clients.
The StorageProvider interface is the most important design decision in the whole project. It is a small surface area that decouples the chunking logic from the storage destination entirely. Wherever you decide to store files — local disk, S3, GCS, Cloudinary, or anywhere else — the chunk upload logic does not change.

That is, ultimately, what clean architecture is for.
Kenapa Custom Hooks Itu Penting?
Reusability - Logic yang sama, cukup tulis sekali
Separation of Concerns - Logic terpisah dari UI
Readability - Code lebih clean dan maintainable
Testing - Lebih gampang di-test secara terpisah
Happy coding!

