🚀 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
React State Updates: Avoiding Batching Issues
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
-
-
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
-
-
5 VS Code extensions that every Frontend Developer must have 👇 1️⃣ Prettier Auto-formats your code on save. No more messy indentation! ✅ 2️⃣ ES7+ React Snippets Type "rafce" and get a full React component instantly! ✅ 3️⃣ GitLens See who wrote which line of code and when — inside VS Code! ✅ 4️⃣ Thunder Client Test your APIs directly in VS Code. No need to open Postman! ✅ 5️⃣ Auto Rename Tag Rename opening HTML tag and closing tag updates automatically! ✅ Save this post for later! 🔖 Which one is your favourite? Comment below! 👇 #VSCode #Frontend #ReactJS #WebDevelopment #JavaScript #Programming #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Default Export vs Named Export in React — Stop Confusing Them! 🔹 Default Export ✔ Only one per file ✔ No curly braces needed ✔ You can rename it while importing export default Header; import MyHeader from "./Header"; --- 🔹 Named Export ✔ Multiple exports allowed ✔ Must use curly braces ✔ Name must match while importing export const add = () => {}; import { add } from "./utils"; --- 🔥 Key Difference 👉 Default = One main thing 👉 Named = Multiple utilities --- Nishant Pal 💬 Which one do you use more — Default or Named? #ReactJS #JavaScript #WebDevelopment #Frontend #Coding #Developers #LearnToCode
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
-
Two lines. Same numbers. Completely different outputs 🤯 👉 "console.log(1 + 2 + "3");" 👉 "console.log("1" + 2 + 3);" Looks simple… but JavaScript has its own way of thinking 👀 Are you sure you know what the output will be? I made a quick video breaking this down — and trust me, it’s NOT what most people expect 🚀 Watch till the end to understand how JavaScript actually evaluates expressions and why order matters more than you think! #JavaScript #WebDevelopment #Coding #Frontend #Developers #JSBasics
To view or add a comment, sign in
-
I just deleted 30 lines of code from a React component. no refactor. no library. just one hook in React 19. it's called use() — and it changes how you handle async data and context in your components. most devs haven't heard of it yet. swipe through ↓ broke it down simply what's the most boilerplate you've deleted in a single React upgrade? 👇 #react #react19 #javascript #webdev #frontend
To view or add a comment, sign in
-
Ever spent hours chasing bugs only to find the simplest mistake? You write code. It doesn’t work. You spend hours debugging. Then suddenly… the bug reveals itself — in the least expected way. Sometimes, the breakthrough is just one insight away. Keep going. #FullStackDeveloper #MERNStack #NodeJS #ReactJS #JavaScript #RESTAPI #ReduxToolkit #TailwindCSS #WebDevelopment #FrontendDevelopment #BackendDevelopment #ResponsiveDesign #TechSolutions #UserFocusedDesign #SoftwareEngineering #CodingLife #DeveloperCommunity #ModernWebApps #ProgrammingTips #WebDevProjects
To view or add a comment, sign in
-
-
🚀 30 Days — 30 Coding Mistakes Beginners Make Day 13/30 I copied an object… and the original data changed 😐 const newUser = user Then I updated newUser… and user also changed. Because objects in JavaScript are stored by reference, not value. Both variables pointed to the same memory. Fix 👇 const newUser = { ...user } Now a new object is created. This concept is very important in React state updates and debugging strange UI behavior. Day 14 tomorrow 👀 #30DaysOfCode #javascript #reactjs #frontend #webdevelopment #codeinuse
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
correct