🚀 Practicing React by building a User Management System Recently, I’ve been practicing React by building a small project where I implemented: 1. Add User 2. Edit User 3. Delete User 4. Form validation using React Hook Form 5. Data persistence using localStorage While practicing, I ran into multiple bugs and learned a lot by debugging them 💥 Key Learnings: 🔹 State is asynchronous I was saving data to localStorage using old state, which resulted in empty arrays ([]). * Fixed it by saving the updated array instead of the old state. 🔹 Immutability matters While updating a user, I forgot to return inside .map() which broke the state. * Learned that state updates must always return a new array. 🔹 Avoid nested arrays I mistakenly did [users, newUser] instead of [...users, newUser] * This caused unexpected UI behavior. 🔹 Functional updates are safer Using: setUsers(prev => [...prev, newUser]) is more reliable than directly using state. 🔹 Attention to small details Even small mistakes like using a string instead of RegEx in validation can break logic. github : https://lnkd.in/gZNF6pxu #ReactJS #FrontendDevelopment #JavaScript #LearningInPublic #WebDevelopment
React User Management System with State and Validation
More Relevant Posts
-
React is unidirectional. Data flows down. If you’ve spent any time in React, you know the drill, parents talk to children via props. It’s predictable, and it’s why the library scales. But it leads to the inevitable question, How does the child talk back? It’s not a "reverse prop" or some hidden magic. It’s actually a classic JavaScript pattern. While data flows down, functions are first-class citizens. To let a child communicate, the parent defines a "handler" function and passes it down as a prop. The child doesn't send data up in the traditional sense, it simply executes the function it was given. This is the essence of lifting state up. The parent keeps the "source of truth," and the child remains reusable, only triggering the parent’s logic when an event occurs. Of course, once you’re passing functions down five levels deep, you’re in prop drilling hell. That’s usually the signal to reach for the Context API or a state manager like Zustand to keep your components clean. Are you - context API purist? - prefer a dedicated state manager for handling these flows? #ReactJS #WebDevelopment #SoftwareEngineering #Frontend #Javascript
To view or add a comment, sign in
-
𝗠𝗮𝘀𝘁𝗲𝗿 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗠𝗲𝗺𝗼𝗿𝘆: 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻 𝗘𝘅𝗽𝗹𝗮𝗶𝗻𝗲𝗱! ♻️ Ever wondered how JavaScript keeps your apps running smoothly without eating up all your RAM? The secret is Garbage Collection (GC)! 🚀 Here is a quick breakdown of how it works: Memory Allocation: When you create objects, strings, or functions, JS automatically reserves a spot in the Memory Heap. 💾 The Reachability Concept: The engine looks for "reachable" values—those that are still accessible from the "roots" (like the global window object or active function calls). 🔗 𝗠𝗮𝗿𝗸-𝗮𝗻𝗱-𝗦𝘄𝗲𝗲𝗽 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺: 1. Mark: The GC "marks" all reachable objects as Alive. ✅ 2. Sweep: It "sweeps" away anything not marked, freeing up that memory for new data. 🧹 𝗣𝗿𝗼-𝗧𝗶𝗽: Avoid memory leaks! If you're done with a large object, set it to null to ensure the GC knows it's ready to be cleared. 💡 Understanding these low-level concepts helps you write more efficient, high-performance code! 💻✨ #JavaScript #WebDevelopment #CodingTips #SoftwareEngineering #ProgrammingConcepts #MemoryManagement
To view or add a comment, sign in
-
-
using shadcn/ui and react-hook-form is the best stack in the react ecosystem but it has one massive flaw which is It is incredibly verbose. every single text input in every application likely looks like this: <FormField control={form.control} name="first_name" render={({ field }) => ( <FormItem> <FormLabel>First Name</FormLabel> <FormControl> <Input placeholder="Enter first name" {...field} /> </FormControl> <FormMessage /> </FormItem> )} /> That is 12 lines of code for one input. If a form has 10 fields, your component balloons to 150+ lines of pure boilerplate. so how did i solve this? simply i made several reusable form molecules with strict JSDoc comments. This will allow replacing those 12 lines with a single, highly readable line: <SharedTextField control={form.control} name="first_name" label="First Name" /> the idea is very simple but from my experience most developer are too lazy to do this kind of solutions thinking it won't make any real difference :)
To view or add a comment, sign in
-
Our team analyzed 70 full-stack applications using TypeScript and tRPC, and the results were eye-opening. We found an average 25% reduction in bugs related to API mismatches. End-to-end type safety is not just a buzzword—it's a real game changer. Have you ever considered the impact of strong typing on your full-stack development process? At first, I was skeptical about the learning curve that adding tRPC would introduce. But integrating these robust types into both the backend and frontend created a synchronized development flow I hadn't experienced before. Imagine defining your API in one single place, and knowing that any changes are instantly reflected wherever it's used—no more chasing down those pesky runtime errors. This became our team's standard with TypeScript and tRPC. When changes happen, the confidence in our code remains unshaken. Here's a quick TypeScript snippet showcasing how effortlessly you can define a tRPC procedure: ```typescript import { initTRPC } from '@trpc/server'; const t = initTRPC.create(); const appRouter = t.router({ getUser: t.procedure .input(z.string()) .query(async ({ input }) => { return await getUserFromDatabase(input); // Assume this fetches a user by ID }), }); ``` This snippet highlights how simple it is to create a type-safe procedure, ensuring the input and output are consistent across the board. So, have you tried tRPC or similar libraries? How do you ensure end-to-end type safety in your projects? #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
Your React component is leaking memory and you have no idea. I just read about this pattern in the docs. I realized I was fighting the React lifecycle for months 😅 The problem? Race conditions from uncleared async requests. When you fetch data on state change: - User changes profile 10 times in 1 minute - 10 API requests fire - Only the LAST response updates state - Previous 9 complete but state is already changed - Memory leak + stale data Most devs skip cleanup. Most tutorials show incomplete examples. Result? Wasted requests, stale data, memory leaks. #React #JavaScript #Performance #WebDevelopment
To view or add a comment, sign in
-
-
Most developers think this is a “small mistake”… But it can break your entire application. Today, I debugged an issue where a search feature was showing old API results. At first glance, everything looked correct: - API was working - State was updating - No errors in console But the problem was subtle 👇 When users typed fast, multiple API calls were triggered. And sometimes, a slower previous request finished after the latest one. Result? 👉 Old data overwrote the new results. This is called a race condition — and it’s more common than people think. 💡 How I fixed it: - Used request cancellation (AbortController) - Tracked latest request ID - Ignored outdated responses Simple fix. Big impact. --- As developers, it’s not always about writing code. It’s about understanding how systems behave under real user conditions. Have you faced something like this in your projects? --- #mernstack #reactjs #webdevelopment #javascript #fullstackdeveloper #softwareengineering #codingtips #frontenddevelopment #backenddevelopment #devcommunity
To view or add a comment, sign in
-
-
Building a real-world application always comes with those “lightbulb” moments… usually after a few hours of frustration 😅 Recently, I spent 3 hours debugging a CRUD project, chasing what felt like a complex issue ,only to discover the real problem was a missing .json() in a fetch call. It’s funny how easy it is to overlook the basics when you're deep into complex logic. That one small mistake reminded me of something important: 👉 In the MERN stack, the connection between frontend and backend depends on small but critical details 👉 If you don’t parse the response, your data is basically locked away This experience reinforced a powerful debugging habit for me: 💡 Always verify your data at the very first step Now, I make it a rule to log the raw response before touching state management. It’s a simple step ,but it can save hours of frustration. Whether you're using Vite, React, or even vanilla JavaScript, the fundamentals of REST APIs stay the same. Sometimes the most “advanced” problems… have the most “basic” solutions. And honestly, once you find the issue , you just laugh and move on 😄 💬 What’s a simple or “silly” bug that taught you a big lesson? #WebDevelopment #MERN #JavaScript #100DaysOfCode #LahoreDevs
To view or add a comment, sign in
-
-
I spent 3 months confused by React. Then I learned Hooks — and everything finally clicked. Most tutorials throw you into class components and lifecycle methods. It's overwhelming. But Hooks changed everything — they made React actually fun to write. Here's the complete mental map I wish I had on day one: ⚡ useState — add local state to any function component ⚡ useEffect — handle side effects (API calls, subscriptions) 🔵 useRef — access DOM elements & persist values without re-rendering 🔵 useContext — share data across the component tree 🟡 useMemo — cache expensive calculations 🟡 useCallback — memoize functions to prevent unnecessary re-renders 🟢 useReducer — manage complex state with reducer logic 🟢 useLayoutEffect — like useEffect, but fires before paint 5 tips to go from beginner → advanced: Master useState & useEffect DEEPLY before moving on Build custom hooks — extract logic you reuse (e.g. useWindowSize) Think in data flow — hooks work best when you understand how state moves Optimize wisely — reach for useMemo/useCallback only when you actually need them Keep building. Real projects teach what tutorials can't. Hooks aren't just syntax — they're a new way of thinking about UI logic. If you're just starting out: be patient with yourself. The mental model takes time. Once it lands, you'll wonder how you ever coded without them. Save this post — it'll make sense in ways it doesn't yet. 🔖 Which Hook was the hardest for you to wrap your head around? Drop it below 👇 #ReactJS #WebDevelopment #JavaScript #Frontend #ReactHooks #Coding #LearnToCode #SoftwareEngineering #100DaysOfCode
To view or add a comment, sign in
-
-
Built a LeetCode Stats Tracker using HTML, CSS & JavaScript! I recently worked on a mini project where I created a LeetMetric Dashboard that allows users to: 🔍 Enter a LeetCode username 📊 Fetch problem-solving stats (Easy / Medium / Hard) 🎯 Display results in a clean circular progress UI 💡 What I learned during this project: Handling API requests (fetch) in JavaScript Dealing with real-world issues like CORS errors & unstable APIs Debugging common mistakes (DOM selection, string handling, etc.) Improving UI using CSS flexbox & conic-gradient ⚠️ Biggest challenge: Public APIs were not reliable, so I had to switch approaches and understand how real APIs and browser restrictions work. ✨ This project helped me move from just writing code → to actually debugging like a developer 🛠️ Tech Stack: HTML | CSS | JavaScript 📌 Next step: Planning to add animations, better UI, and more detailed stats! #JavaScript #WebDevelopment #Frontend #Coding #LearningByDoing #100DaysOfCode
To view or add a comment, sign in
-
I was repeating the same logic in every component… and it started getting messy 😅 Yes, seriously. For a long time, I was doing this in React: useEffect(() => { fetchData(); }, []); const [data, setData] = useState(); const [loading, setLoading] = useState(false); Same pattern… in multiple components ❌ ⚠️ This caused: • Code duplication • Hard-to-maintain components • Bigger, messy files 💡 Then I changed my approach: Instead of repeating logic everywhere, 👉 I created a custom hook 🧠 Example: useFetch(url) Handles: • API call • Loading state • Error handling ✅ Result: • Cleaner components • Reusable logic • Easier maintenance 🔥 What I learned: If you’re repeating the same logic… you’re probably missing a custom hook. #ReactJS #FrontendDeveloper #JavaScript #CodingTips #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