Dev.to WebDev 🛠 Dev 👁 1 📖 1 min read

How I Built a Form Builder with Next.js 16 and Supabase

Three weeks ago I built a form builder. Not a company — just a tool I needed. Here are the three bugs that cost me the most time. Bug #1 — React state closure Typing in the question editor did nothing. The l

Cover image for How I Built a Form Builder with Next.js 16 and Supabase
builtstack
builtstack

Posted on Sep 25

How I Built a Form Builder with Next.js 16 and Supabase

Three weeks ago I built a form builder. Not a company — just a tool I needed.

Here are the three bugs that cost me the most time.

Bug #1 — React state closure

Typing in the question editor did nothing. The letters didn't appear.

Cause: I was mapping over state directly instead of using the functional update form.


typescript
// ❌ Broken
setBlocks(blocks.map((b) => b.id === id ? { ...b, label } : b));

// ✅ Correct
setBlocks((prev) => prev.map((b) => b.id === id ? { ...b, label } : b));
Enter fullscreen mode Exit fullscreen mode
DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.