🚀 30 Days — 30 Coding Mistakes Beginners Make Day 7/30 I typed inside an input… clicked “Add new item”… and the text moved to another field 😳 The bug? key={index} I used array index as React key. React does not track elements. React tracks keys. When list order changes, React reuses DOM nodes, so your input becomes a different item. Fix 👇 key={item.id} Stable key = stable UI. React warnings are not decoration… they are future bugs. Day 8 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment #codeinuse
React Key Mistakes for Beginners
More Relevant Posts
-
🚀 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
To view or add a comment, sign in
-
-
🚀 30 Days — 30 Coding Mistakes Beginners Make Day 10/30 I increased state twice… but it only updated once 😐 setCount(count + 1) setCount(count + 1) I expected +2 I got +1 Because React batches state updates. Both lines used the same OLD value of `count`. Fix 👇 setCount(prev => prev + 1) Functional updates always receive the latest state. This is very important in: counters, carts, likes, and real-time UI. Day 11 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment #codeinuse
To view or add a comment, sign in
-
-
🚀 30 Days — 30 Coding Mistakes Beginners Make Day 9/30 I built a form in React… and used: document.getElementById("name").value It worked. But later validation broke, reset didn’t work, and UI went out of sync 😐 Because React was not controlling the input. The DOM was. Correct way 👇 Use controlled input with state. <input value={name} onChange={e => setName(e.target.value)} /> In React: State should control UI not the DOM. This is why React forms become predictable and easier to debug. Day 10 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment #codeinuse
To view or add a comment, sign in
-
-
🚀 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
-
-
🚀 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
-
-
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
-
-
🚀 30 Days — 30 React Mistakes Beginners Make 📅 Day 4/30 ❌ Mistake: Making Input Controlled Without onChange I wrote this 👇 <input value={name} /> Input stopped typing 😐 💡 Why? When you pass value, React controls the input. But without onChange, it becomes read-only. React says: “If I control it, you must update it.” ✅ Correct Way <input value={name} onChange={(e) => setName(e.target.value)} /> 🎯 Lesson If you use value, always handle onChange. Controlled component = state-driven input. #ReactJS #JavaScript #FrontendDev #WebDevelopment #CodingProblems #ReactHooks #DevTips #ProgrammingLife #TechLearning #UIEngineering
To view or add a comment, sign in
-
-
I wasted 3 months watching React tutorials. Rewatching. Taking notes. Feeling "ready." Then I opened VS Code and went completely blank. Sound familiar? Here's the thing nobody tells you — tutorials teach you to follow, not to build. And there's a massive difference between the two. So I made this instead. 5 core React concepts. Zero fluff. One slide each. → Components → Props → useState → useEffect → Rendering Lists That's literally 80% of what you need to start building real projects. Save this. Open your editor. Break something. That's how you actually learn React. 🔖 Save this post before you forget ♻️ Repost if this would help someone in your network #React #ReactJS #WebDevelopment #Frontend #JavaScript #LearnToCode #100DaysOfCode #Developer #Coding #wasaydevops
To view or add a comment, sign in
-
🚀 Today I Learned: React Lifecycle (Class vs Functional Components) Today I spent some time understanding how React components live, update, and disappear inside an application. This concept is called the React Lifecycle. Every component in React goes through three main phases: 🔹 Mounting – When a component is created and added to the DOM for the first time. In class components this involves steps like the constructor, rendering the UI, and then running logic after the component is mounted. 🔹 Updating – This phase happens whenever state or props change. React re-renders the component and updates the DOM with the new changes. 🔹 Unmounting – This is when a component is removed from the DOM. Any cleanup logic should happen here. One interesting thing I realized is how functional components handle lifecycle differently compared to class components. Instead of multiple lifecycle methods, functional components mainly rely on effects and dependencies to control behavior during mounting, updating, and unmounting. 💡 My key takeaway today: Even though the implementation looks different in class and functional components, the core lifecycle phases remain the same — Mount → Update → Unmount. Understanding this makes it much easier to reason about when and why React components run certain logic. Learning React step by step and connecting these concepts is starting to make the framework feel much more intuitive. #ReactJS #FrontendDevelopment #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode #DeveloperLife #Coding #BuildInPublic #CodingChallenge #FrontendDeveloper #DeveloperJourney #WebDevCommunity #MERNStack #Consistency #TechLearning #FullStack
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