I Thought This Was Easy ! Date: 9/4/2026 Today, I tried another React.js project: Transfer List. When I saw it for the first time, I realized this is too easy—only a game with array, and state updates. 😎 But? When I tried it, I got stuck ! 🤣 🤣 The first two functionalities—moving all items from the left box to the right box and vice versa—I made easily. 😊 But moving only checked items was the most challenging part of this project.🤔 Disabling buttons based on conditions (most time-consuming). After making this project, what I learned: 👉 Improved logical thinking about states. 👉 I learned why the Double-Bang operator is important. 👉 Strong command of filtering. And from what I know, these are the weak areas where improvement is required: 👉 Controlled Components 👉 I always use useState; I need to practice useReducer more. Github Repo - https://lnkd.in/gK9cqYxm #ReactJS #WebDevelopment #CodingJourney #JavaScript #CodeNewbie
More Relevant Posts
-
I used to think I understood React state… until this small thing proved me wrong. I wrote this: setCount(count + 1) setCount(count + 1) setCount(count + 1) And I was expecting the count to go up by 3. But it only increased by 1. At first, it made no sense. Then I realized what was actually happening… React doesn’t update state immediately. It batches those updates and runs them later. So all three lines were using the same old value of `count`. Basically, I was doing: 0 → 1, 0 → 1, 0 → 1 Final result: 1 That’s when I learned to use functional updates: setCount(prev => prev + 1) Now each update gets the latest value: 0 → 1 → 2 → 3 Such a small change, but it completely fixed the logic. Since then, I follow one simple rule: 👉 If the new state depends on the previous one, always use a function. It’s one of those things that seems obvious later… but only after it breaks your code once 😅 Curious — has something like this ever confused you in React? #react #javascript
To view or add a comment, sign in
-
-
🧠 React Doesn’t Update State Immediately (Even Inside the Same Function) Most people know state is async. But here’s the part many don’t realize 👇 Example const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); if (count === 0) { console.log("Still zero?"); } } You click the button. Expected: count = 1 But inside that function… 👉 count is still 0 🔍 Why? Because React doesn’t update state inside the current render cycle. It schedules the update and re-renders later. 🧠 The tricky part Even this won’t work: setCount(count + 1); setCount(count + 1); 👉 Final result = +1, not +2 ✅ Correct way setCount(prev => prev + 1); setCount(prev => prev + 1); Now React uses the latest value. 🎯 The Real Insight State inside a function is a snapshot, not a live value. 💥 Why this matters This causes: Unexpected conditions Wrong calculations Confusing bugs #ReactJS #FrontendDevelopment #JavaScript #ReactHooks #WebDevelopment #CodingTips #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 967 of #1000DaysOfCode ✨ useEffect Hook in React (Explained Simply) `useEffect` is one of the most powerful hooks in React — but also one of the most misused. In today’s post, I’ve explained the `useEffect` hook in a simple and practical way, so you can understand how and when to use it correctly. From handling API calls to managing subscriptions and syncing data, `useEffect` helps you deal with side effects in your components. The tricky part is understanding dependencies — which often leads to bugs like infinite loops or missed updates. I’ve also covered common mistakes developers make and how to avoid them in real-world applications. If you’re working with React, mastering `useEffect` will make your code much cleaner and more predictable. 👇 What’s the most confusing part of `useEffect` for you — dependencies or execution timing? #Day967 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #ReactJS
To view or add a comment, sign in
-
Props vs State in React Most beginners get confused between Props and State in React. At first, both seem similar because both store data. But the real difference is simple: * Props = Data received from another component * State = Data managed inside the component Example: function Parent() { return <Child name="Durgesh" />; } function Child(props) { return <h1>{props.name}</h1>; } Here, `name` is a prop because it comes from the Parent component. Now look at State: const [count, setCount] = useState(0); Here, `count` is managed inside the same component. Quick Difference 👇 • Props are read-only • State can be updated • Props come from parent to child • State belongs to the component itself Think like this: Props = Things you receive State = Things you control Once you understand this difference, React becomes much easier. What confused you more when learning React — Props or State? #react #javascript #frontend #webdevelopment #reactjs #coding
To view or add a comment, sign in
-
-
JavaScript runs everywhere — your browser, your server, your smart TV. That's not magic. That's the 𝐑𝐮𝐧𝐭𝐢𝐦𝐞 𝐄𝐧𝐯𝐢𝐫𝐨𝐧𝐦𝐞𝐧𝐭. I always assumed JS just... ran. Didn't think about what makes that possible. Turns out, without a runtime — there's nothing. The 𝐉𝐒 𝐄𝐧𝐠𝐢𝐧𝐞 is the heart of it all. No engine, no runtime. No runtime, no execution. 𝐄𝐯𝐞𝐫𝐲 𝐞𝐧𝐯𝐢𝐫𝐨𝐧𝐦𝐞𝐧𝐭 𝐭𝐡𝐚𝐭 𝐫𝐮𝐧𝐬 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭 — 𝐛𝐫𝐨𝐰𝐬𝐞𝐫, 𝐍𝐨𝐝𝐞.𝐣𝐬, 𝐚𝐧𝐲𝐭𝐡𝐢𝐧𝐠 — 𝐢𝐬 𝐣𝐮𝐬𝐭 𝐚 𝐫𝐮𝐧𝐭𝐢𝐦𝐞 𝐛𝐮𝐢𝐥𝐭 𝐚𝐫𝐨𝐮𝐧𝐝 𝐚𝐧 𝐞𝐧𝐠𝐢𝐧𝐞. Here's what clicked: → 𝐁𝐫𝐨𝐰𝐬𝐞𝐫 has its own JS Runtime — built-in, ships with every browser → 𝐍𝐨𝐝𝐞.𝐣𝐬 is an open-source runtime that runs JS outside the browser → Both share common API names — but their internal implementation is always different And the governing body behind it all? 𝐄𝐂𝐌𝐀 𝐒𝐜𝐫𝐢𝐩𝐭 — the organisation that defines what JavaScript even is. The first JS engine was built by 𝐁𝐫𝐞𝐧𝐝𝐚𝐧 𝐄𝐢𝐜𝐡 himself (the creator of JavaScript). Today it lives inside Firefox as 𝐒𝐩𝐢𝐝𝐞𝐫𝐌𝐨𝐧𝐤𝐞𝐲. → Save this before you need it. #BuildingInPublic #JavaScript #SoftwareEngineering #DeveloperJourney #LearningInPublic #Programming #TechCommunity #WebDevelopment
To view or add a comment, sign in
-
-
most React developers use useCallback wrong. not because they don't understand it. because they were taught the wrong rule. the rule they heard: "wrap functions in useCallback to prevent unnecessary re-renders. the actual rule: useCallback only helps when you pass that function to a child component wrapped in React.memo or as a dependency in useEffect. that's it. useCallback doesn't prevent re-renders of the parent. it just memoizes the function reference so children don't see a "new" function every render. three questions to ask before reaching for useCallback: - is this function passed to a memoized child component? - is this function a dependency in a useEffect? - is this function expensive to recreate? if none of these just write the function normally. the best optimisation is usually the one you don't add. #reactjs #typescript #webdevelopment #buildinpublic #javascript
To view or add a comment, sign in
-
-
🐛 A small bug wasted 3 hours of my time. I was building a React project. Everything looked correct. The API was working. The component was rendering. There were no errors in the console. But the UI was still not updating. For 3 hours, I kept checking the wrong things. Then I finally noticed the problem. I was directly mutating the state instead of creating a new one. Something as small as this: ❌ state.push(newItem) ✅ setState([...state, newItem]) And suddenly, everything started working. That moment reminded me of something important: In development, the biggest problems are often caused by the smallest mistakes. Since then, whenever something doesn’t work, I try to remember: • Don’t panic • Check the basics first • Read the code slowly • Small details matter Because debugging is not just about fixing bugs. It’s about learning how to think better. 💬 What is one bug that taught you an important lesson? #ReactJS #JavaScript #debugging #webdevelopment #developers #learning #softwareengineering
To view or add a comment, sign in
-
One of the biggest mistakes I made early in React: 👉 Overusing useEffect. After working with React for 3 years, I realized: Most useEffect usage is unnecessary. Here’s when you should NOT use useEffect 👇 ❌ 1. Deriving state from props If you can calculate it directly during render, don’t store it in state. Bad: const [fullName, setFullName] = useState("") useEffect(() => { setFullName(firstName + " " + lastName) }, [firstName, lastName]) Better: const fullName = firstName + " " + lastName ❌ 2. Handling simple calculations React re-renders already — no need for effects. ❌ 3. Updating state based on another state This often leads to unnecessary re-renders or bugs. ✅ When should you use useEffect? API calls Subscriptions (e.g., WebSocket) DOM side effects 💡 Rule I follow now: “If it can be calculated during render, don’t use useEffect.” This one shift made my code: ✔ Simpler ✔ Easier to debug ✔ More performant React is powerful — but only when used correctly. What’s one mistake you used to make in React? #React #FrontendDevelopment #JavaScript #CleanCode #WebDev
To view or add a comment, sign in
-
when I first started React I was so confused about useState and useEffect like what is the difference and when do I use which one so let me explain both with one simple real example 👇 imagine you are building a weather app that fetches weather data when the page loads here is how useState and useEffect work together in that const [weather, setWeather] = useState(null) useEffect(() => { fetch('https://lnkd.in/g7JkAAtU') .then(res => res.json()) .then(data => setWeather(data)) }, []) that is it. two hooks. one job each. useState stores the weather data useEffect fetches it when the component loads simple way to remember it 👇 useState = where you keep your data useEffect = where you do something when something happens when I understood this everything in React started making sense if you are just starting React and feeling confused about these two, save this post. you will need it 🙌 anything else in React that confused you when you started? drop it in the comments 👇 #React #JavaScript #Frontend #WebDev #ReactJS #100DaysOfCode #Programming #LearnToCode
To view or add a comment, sign in
-
TypeScript Started. Migrating SafelyRest from JavaScript to TypeScript Links:- • GitHub https://lnkd.in/gwfXsp_3 • App https://lnkd.in/d5JnhrGz • Configured "tsconfig" with strict mode • Added strong typing across controllers, services, and models • Replaced "any" with proper types, interfaces, and generics • Implemented type-safe API requests/responses • Added types for env variables and external libraries • Improved async handling with proper Promise types • Better debugging with compile-time error detection #typescript #javascript #backend #fullstack #nodejs #webdevelopment
To view or add a comment, sign in
-
More from this author
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
Good