🚀 30 Days — 30 Coding Mistakes Beginners Make Day 15/30 I changed the state… but the input field didn’t update 😐 <input defaultValue={name} /> `defaultValue` only sets the initial value. After that, the DOM controls the input — not React. So even when state changed, UI didn’t. Fix 👇 <input value={name} onChange={e => setName(e.target.value)} /> Now React state controls the input. In React: Uncontrolled input → unpredictable Controlled input → reliable Day 16 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment #codeinuse
React Input Control Mistakes
More Relevant Posts
-
🚀 30 Days — 30 Coding Mistakes Beginners Make Day 18/30 I clicked “Add Item”… nothing happened 😐 No error. No warning. Button worked. My code: items.push("New Task") setItems(items) The array DID change. But React didn’t update UI. Why? Because React doesn’t check contents. React checks references. Same array reference = React thinks nothing changed. Fix 👇 setItems([...items, "New Task"]) Create a NEW array instead of modifying the old one. This single mistake causes many: “React state not updating” moments. Save this — you will hit this bug in a real project. #30DaysOfCode #reactjs #javascript #frontend #codeinuse
To view or add a comment, sign in
-
-
Learning React made me realize something — frontend isn’t about “changing elements.” It’s about controlling state and thinking in systems. Once that clicked, everything started making sense. Still early in the journey, but the foundation is getting stronger every day. Next stop: advanced hooks and performance optimization. Building > consuming. #ReactJS #JavaScript #FrontendDeveloper #WebDevelopment #CodingJourney #LearnInPublic #FullStackPath
To view or add a comment, sign in
-
-
Forms in React can get messy really fast. I recently explored React Hook Form, and it made things much simpler. Instead of handling state for every input manually, it uses refs and uncontrolled components to manage form data efficiently. 1. Less boilerplate code 2. Simple and flexible validation 3. Fewer re-renders -> better performance It keeps your code clean and improves user experience without adding complexity. If you're building forms in React, this is definitely worth trying. #react #webdevelopment #javascript #frontend #coding
To view or add a comment, sign in
-
-
🚀 30 Days — 30 Coding Mistakes Beginners Make Day 16/30 My component received a new userId… but UI still showed the old user 😐 The reason? I wrote: useEffect(() => { fetchUser(userId) }, []) Empty dependency array means: run only once on mount. So when userId changed, React never fetched new data. Fix 👇 useEffect(() => { fetchUser(userId) }, [userId]) Dependencies tell React WHEN to re-run the effect. Missing dependency = stale UI data. Day 17 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment #codeinuse
To view or add a comment, sign in
-
-
🚀 30 Days — 30 Coding Mistakes Beginners Make Day 17/30 I wrote an API call inside `useEffect`… and React showed a warning 😐 useEffect(async () => { const res = await fetch("/api/users") }, []) The mistake: `useEffect` should NOT be async. React expects the effect to return either: nothing, or a cleanup function. But async always returns a Promise. Fix 👇 Create an async function INSIDE the effect and call it. useEffect(() => { async function fetchUsers() { ... } fetchUsers() }, []) Small change. Correct lifecycle behavior. Day 18 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment
To view or add a comment, sign in
-
-
Frontend Learning — Don’t Mutate State Directly As frontend developers, we sometimes update state directly… especially with objects or arrays. It might seem to work, but it can break your UI in unexpected ways. Why this is a problem: -> React may not detect changes -> UI might not re-render -> Leads to unpredictable bugs -> Breaks immutability principles 💡 Key Takeaway: Always create a new copy of state instead of mutating it. ⚡ Common Mistake: Directly modifying state ✅ Better Approach: Use immutable updates #ReactJS #FrontendDevelopment #JavaScript #WebDevelopment #CleanCode #BestPractices #CodingTips #LearnInPublic #DeveloperJourney
To view or add a comment, sign in
-
-
One thing I’ve been doing more often while building features is testing small pieces of logic before moving forward. Not full testing frameworks — just simple checks while the code is running. Clicking the same button multiple times. Trying unexpected inputs. Refreshing the page in the middle of a request. Sometimes that’s where small issues appear. A state that doesn’t reset. A value that becomes undefined. A component that behaves differently after a refresh. Catching those small things early makes the feature feel much more solid. It’s a quiet part of development, but it makes a big difference once everything starts coming together. Still building. Still learning from the small details inside the code. #FrontendDevelopment #ReactJS #JavaScript #WebDevelopment #SoftwareDevelopment
To view or add a comment, sign in
-
🚀 React.js Basics: Understanding Props vs State While learning and building projects in React.js, one of the most important concepts to understand is the difference between Props and State. 🔹 State Managed inside the component Can change over time Used for dynamic data like counters, forms, UI updates 🔹 Props Passed from parent to child components Read-only (cannot be modified by the child) Used to share data between components 💡 Simple way to remember: State = Internal data of a component Props = Data passed from parent component Understanding these two concepts clearly helps in building clean, reusable, and scalable React components. I created this visual to make the concept easier for beginners who are learning React UI Development. 🌐 Explore my work: https://allconverthub.com https://lnkd.in/g4Hnzt9Z #ReactJS #FrontendDevelopment #UIDeveloper #JavaScript #WebDevelopment #ReactLearning #FrontendEngineer #Coding
To view or add a comment, sign in
-
-
Built a simple To-Do List App using HTML and JavaScript. where users can add and delete tasks dynamically. While building this project, I practiced DOM manipulation, event handling, and dynamically creating elements in JavaScript. Small projects like this help strengthen the basics. 🚀 #javascript #webdevelopment #frontend #coding #learningbydoing
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
I never saw beginners make this mistake