🚀 Just built the Tic-Tac-Toe game using React (from the official docs)! This project taught me not only core React concepts but also helped me fix some tricky bugs that improved my understanding. Key Concepts I Learned 🔹 Breaking UI into reusable components (Square, Board) 🔹 Passing data & callbacks using props 🔹 Managing state with useState 🔹 Why immutability matters (slice() before updating) 🔹 Clean one-way data flow from parent → child 🔹 Writing pure helper functions like calculateWinner() 🔹 Conditional rendering for displaying game status Interesting Bugs I Fixed Along the Way 🐞 1. Wrong loop condition (lines[0].length) I mistakenly used lines[0].length instead of lines.length in the winner-checking loop. This caused the winner function to stop early and fail in some cases. Fixing it helped me understand how array-of-arrays work in JavaScript. 🐞 2. Missing <> </> fragment wrapper At one point I didn’t wrap JSX elements inside a fragment, causing compilation errors. This taught me how JSX must always return a single parent element. 🐞 3. Infinite re-render confusion I learned the difference between: ✔ passing a function → onClick={() => handleClick(0)} ✘ calling a function during render → onClick={handleClick(0)} Understanding this removed my confusion about unnecessary re-renders. Overall Takeaway This small project helped me understand how React really works: state updates trigger re-renders, JSX must be well-structured, and immutability + pure functions make the UI predictable. Excited to keep building more projects! ⚡ #react #javascript #webdevelopment #frontenddevelopment #reactjs #learninginpublic #codingjourney #softwareengineering #programming #developers #100daysofcode #projectbasedlearning #webdev
More Relevant Posts
-
React just made forms less painful – meet useActionState 😎 🧠 Truth bomb: For years, every React developer has written the same 3 things for forms: useState, useEffect, and... a whole lot of tears 😅 We handled loading states, success messages, and API responses manually — basically doing the same thing every single time 🙄 💡 Now enters React 19’s superhero: useActionState 🦸♂️ It takes care of your form submissions, state updates, and loading indicators — all in just a few lines of code. No more juggling multiple hooks like: const [data, setData] = useState(); const [loading, setLoading] = useState(); const [error, setError] = useState(); Now it’s simply: const [state, action, isPending] = useActionState(yourAction, initialState); and boom 💥 — React handles the rest. 🎭 Fun fact: Before this hook, React devs were basically doing “form yoga” — trying to balance async actions, error states, and spinners in one file. 🧘♂️ Now, it’s finally one smooth flow. 🔥 When to use it? 1. Form submissions (client or server actions) 2. Async API calls 3. Handling UI states without spaghetti code 🍝 💬 Your turn: Have you tried useActionState yet? What’s the most chaotic form handling experience you’ve had in React? 😂 Drop your funniest story below 👇 #JavaScript #WebDevelopment #CodingHumor #FrontendDevelopment #TechEducation #ProgrammingFun #LearnToCode #CodeNewbie #DeveloperCommunity #100DaysOfCode
To view or add a comment, sign in
-
⚛️ React never stops amazing me! Every time I dive deeper, I find new techniques that make building UIs smoother, faster, and more enjoyable. Some of my personal favorites lately: ✨ Component composition – Crafting small, reusable pieces that come together beautifully. ⚙️ Custom hooks – Turning repeated logic into clean, shareable functions. 🎯 Performance optimization – Using memo, useCallback, and lazy loading the smart way. 🧩 Context patterns – Managing app-wide state without unnecessary re-renders. 🚀 Code splitting – Keeping apps lightweight and fast with dynamic imports. React is not just a library — it’s a mindset of modular, declarative, and flexible development. What’s your favorite React trick or pattern that makes your code shine? 💬 #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #ReactHooks #Coding #SoftwareEngineering #UIUX #DevCommunity
To view or add a comment, sign in
-
🚀 Day 3/7 — TypeScript Mini Project Interactive Quiz App (pure TypeScript, no frameworks) What I built • 5 multiple‑choice questions (A/B/C/D) • Progress bar + instant feedback (✓ / ✗) • Final score + restart • Clean, responsive UI How it works • Interface IQuestionData { questionText, options[], correctAnswerIndex } • Class QuizLogic → getCurrentQuestion, submitAnswer, isFinished, getScore • DOM‑only functions → renderQuestion, renderResults, setupEventListeners, showFeedback • Strict TS config (noImplicitAny, strictNullChecks) Why it matters • Strong typing catches bugs early • Class‑based state keeps flow simple and testable • Zero‑dependency builds are fast and portable Tech stack TypeScript (ESNext, strict) • HTML • CSS Key learnings 1) Interfaces as clear contracts 2) Encapsulation with classes 3) Type‑safe DOM manipulation Question for you How do you structure quiz/game logic in TS — classes or functional? Github Repo : - https://lnkd.in/e8q57Pkt open for contribution read contribution.md and follow code of conduct. Waiting for ur contributions... #TypeScript #JavaScript #WebDevelopment #Frontend #CleanCode #LearnToCode #Programming #Developer #Coding #TypeSafety
To view or add a comment, sign in
-
⚛️ That moment when I finally understood useCallback() 😅 While working on a React project, I had a parent component that passed a function down to a child via props. Everything looked fine — until I noticed my child component was re-rendering every time I clicked anything, even if the data didn’t change! 🤯 After a few rounds of confusion (and console logs everywhere 😆), I discovered the culprit: React was re-creating the function on every render. That’s when I met my new best friend — useCallback() 💪 Here’s how it saved me 👇 ❌ Before: function Parent() { const [count, setCount] = useState(0); const handleClick = () => console.log("Clicked!"); return <Child onClick={handleClick} />; } ✅ After using useCallback(): function Parent() { const [count, setCount] = useState(0); const handleClick = useCallback(() => console.log("Clicked!"), []); return <Child onClick={handleClick} />; } 💡 Lesson learned: useCallback() tells React: 👉 “Hey, this function is the same unless dependencies change.” No more unnecessary re-renders. 🚀 React isn’t just about writing components — it’s about learning how to make them efficient! #ReactJS #useCallback #WebDevelopment #MERNStack #FrontendDeveloper #PerformanceOptimization #LearningByDoing #JavaScript #ReactHooks
To view or add a comment, sign in
-
Ever wrestled with getting your React child components to talk to their parent? 🤯 It's a common hurdle, but crucial for building dynamic and interactive UIs! This Dev.to article dives deep into the art of Child-to-Parent Communication in React. You'll learn: * **How to effectively pass data up the component tree.** * **Implement practical examples like adding, deleting, and toggling items.** * **Understand the core concepts with clear, concise examples.** Level up your React skills and build more robust applications. This guide will clarify the concepts and give you practical solutions to implement. 🔗 Read full article: https://lnkd.in/gdi9s9cm #ReactJS #JavaScript #WebDevelopment #Coding #FrontendDevelopment
To view or add a comment, sign in
-
⚛️ Day 1 of my React Series — Let’s start with Components Ever wondered what a React component really is? It’s simpler than it sounds 👇 A React Component is just a JavaScript function that returns markup. But here’s the twist — it doesn’t return HTML, it returns JSX! JSX looks like HTML but works like JavaScript — that’s what makes React so powerful and declarative. 💡 In simple words: Think of components as LEGO blocks — reusable pieces that combine to build entire UIs. 🧩 One component for a button, one for a card, one for a navbar — and together, they make your app. #React #JavaScript #FrontendDevelopment #WebDevelopment #Learning #ReactJS #Frontend #Coding
To view or add a comment, sign in
-
-
𝙍𝙚𝙖𝙘𝙩 𝙃𝙤𝙤𝙠𝙨 𝙄 𝙒𝙞𝙨𝙝 𝙄 𝙆𝙣𝙚𝙬 𝙀𝙖𝙧𝙡𝙞𝙚𝙧 Let’s be honest, when you first start building with React, 𝘂𝘀𝗲𝗦𝘁𝗮𝘁𝗲 and 𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁 feel like superheroes. Then you discover 𝘂𝘀𝗲𝗠𝗲𝗺𝗼 and 𝘂𝘀𝗲𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸, and you’re like, “Yeah, I’ve cracked the React code.” Well… not quite. 😂 There are a few underrated hooks that completely changed how I write cleaner, smarter, and more efficient components. Here are 3 that deserve way more hype: 1. 𝘂𝘀𝗲𝗜𝗺𝗽𝗲𝗿𝗮𝘁𝗶𝘃𝗲𝗛𝗮𝗻𝗱𝗹𝗲: Lets you control what a parent can access from a child component. No more unnecessary prop drilling chaos. 2. 𝘂𝘀𝗲𝗟𝗮𝘆𝗼𝘂𝘁𝗘𝗳𝗳𝗲𝗰𝘁: Perfect when you need to measure or adjust the DOM before it renders on screen. No more layout flickers or surprise jumps. 3. 𝘂𝘀𝗲𝗗𝗲𝗳𝗲𝗿𝗿𝗲𝗱𝗩𝗮𝗹𝘂𝗲: Keeps your UI smooth during heavy renders. I’ve used it in large forms and search bars, and the difference was night and day. These hooks didn’t just simplify my code, they made my development flow cleaner and more enjoyable. I’ve shared a few of these experiments and mini-projects on my GitHub ( https://lnkd.in/eP9nmTEw ) if you love exploring real-world React setups. Building products that scale and perform well (no matter where in the world the team is) has become something I genuinely enjoy diving into. What about you, which React hook do you think doesn’t get enough credit? #ReactJS #FullstackDeveloper #WebDevelopment #Frontend #ReactHooks #JavaScript #CodingHumor #CleanCode #DevLife #RemoteWork #GitHub
To view or add a comment, sign in
-
-
I'll never forget the first time I understood why my React component kept showing "0" on the screen. It was my third week using React. I was building a simple cart component. When the cart was empty, I wanted to show nothing. Seemed straightforward. I wrote: {cartItems.length && <CartDisplay items={cartItems} />} Tested it with items in the cart. Worked perfectly. Deployed. Then a user sent a screenshot: just a "0" floating on an otherwise empty page. I was confused. "If cartItems.length is 0, shouldn't it render nothing?" Spent an hour debugging. Checked state. Checked props. Everything looked right. But that 0 kept appearing. Finally Googled: "React rendering 0 instead of nothing" Turns out: In JavaScript, 0 is falsy. In React JSX, 0 is a valid child that gets rendered. Mind blown. The fix was simple: {cartItems.length > 0 && <CartDisplay items={cartItems} />} But that one bug taught me something bigger: conditional rendering in React isn't just JavaScript logic. It's about understanding what React considers "renderable." After that, I started seeing conditional rendering everywhere. Loading states. Error messages. Empty states. User permissions. Each one needed a different pattern. Now I know: Use && only with booleans or explicit comparisons Ternary for if-else scenarios Early returns for complex conditions Always handle the "nothing to show" case This breakdown covers everything I learned: → All the ways to conditionally render (with real examples) → When each pattern makes sense → The 0 bug and other gotchas → Handling loading/error/empty states properly → Patterns that won't surprise you later If you've ever been confused by conditional rendering—or shipped a bug because of it—this is for you. #ReactJS #WebDevelopment #JavaScript #ConditionalRendering #LearningToCode #DeveloperJourney #LearnReact #Developers #CodingLife #TechCareer #looking #for
To view or add a comment, sign in
-
🚀 Just published: React 19.2 Just Killed useEffect (And I'm Not Even Mad About It) — a deep dive into how React’s latest async features like Suspense, the use hook, and ViewTransition are transforming the way we build apps! If you've ever struggled with managing loading states, callbacks, or complex data fetching in React, this article is for you. I break down: * Why the old useEffect way is becoming obsolete * How throwing promises is now React's secret weapon * Hands-on code examples to master these new patterns * And how GPU-accelerated animations via ViewTransition will blow your mind 🧙♂️✨ Curious about how these game-changing features can simplify your React code and boost performance? Check it out here 👉 https://lnkd.in/dbFPiGTc #ReactJS #JavaScript #WebDevelopment #AsyncProgramming #React192 #FrontendDevelopment #TechWriting
To view or add a comment, sign in
-
🚀 Mastering Props in React — The Key to Reusable Components! In React, props (properties) are one of the most powerful concepts. They allow you to pass data from one component to another, making your UI dynamic, reusable, and easier to maintain. Think of props as function arguments — you send data from parent to child so the child can render content based on that data. 🔍 Why Props Matter? ✔️ Help create reusable components ✔️ Support one-way data flow ✔️ Make apps more organized and modular ✔️ Keep components dynamic and flexible 📌 Simple Example // Parent Component function App() { return ( <div> <Greeting name="Amy" /> <Greeting name="React Learner" /> </div> ); } // Child Component function Greeting(props) { return <h2>Hello, {props.name}! 👋</h2>; } 💡 Here, the App component passes different name values as props to the Greeting component — making it reusable and dynamic. 🧠 Pro Tip Use destructuring for cleaner code: function Greeting({ name }) { return <h2>Hello, {name}! 👋</h2>; } ✨ If you're learning React, understanding props is your first big step toward building powerful, component-driven UIs! #React #ReactJS #WebDevelopment #Frontend #JavaScript #LearnReact #Coding #Developers #PropsInReact #ReactTips #WomenWhoCode #CodeNewbie #Programming #TechLearning #ReactComponents #FrontendDevelopment #100DaysOfCode #SoftwareEngineering #BuildInPublic
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