😂 Day 40/100 – Random Joke Generator using JavaScript & API Fetch 🚀 Day 40 of the #100DaysOfCode challenge is all about mixing humor with learning! I built a fun Random Joke Generator App 🎭 that fetches a new joke each time you click the button. ✨ What I learned today: 🔹 Fetching data from public APIs using fetch() 🔹 Handling asynchronous operations with .then() and .catch() 🔹 Dynamically updating the DOM with fetched content 🔹 Displaying a spinner while the data loads for better UX This project was a light-hearted yet powerful lesson in real-world API handling and frontend interactivity 😄 #100DaysOfCode #JavaScript #WebDevelopment #Frontend #CodingChallenge #LearningByDoing #NxtWave #APIIntegration #CCBP #AsyncJS #FunWithCode
More Relevant Posts
-
⚛️ React Component Lifecycle — the hidden rhythm behind every UI. Every React component has a journey — from being created, shown, updated, and finally removed. Understanding this lifecycle helps you write cleaner, faster, and more predictable React code. --- 🧩 What is the Component Lifecycle? The lifecycle represents different stages a component goes through during its existence — like Mounting, Updating, and Unmounting. Each stage gives us hooks (or class methods) to run code at just the right moment. --- 🔹 1. Mounting — This is when your component first appears on the screen. You usually fetch data, set up event listeners, or initialize states here. In React hooks: useEffect(() => { console.log("Component mounted!"); }, []); --- 🔹 2. Updating — When something changes. Whenever props or state update, React re-renders your component. You can track or respond to these changes here. In hooks: useEffect(() => { console.log("Component updated!"); }); --- 🔹 3. Unmounting — When the component says goodbye. When the component is removed from the DOM — clean up everything here: cancel API calls, remove listeners, clear timers, etc. In hooks: useEffect(() => { return () => console.log("Component unmounted!"); }, []); --- 💡 Why does it matter? ⚙️ Performance — Run logic only when needed. 🧹 Clean Side Effects — Avoid memory leaks or unwanted API calls. 🔍 Debugging — Know when and why your component re-renders. 🧠 Deeper React Insight — Understand how your app truly “lives” on the browser. --- React’s lifecycle isn’t just theory — it’s the heartbeat of every interactive experience. Once you understand it, your components won’t just work — they’ll feel alive 💙 #react #javascript #frontend #webdevelopment #coding #learning
To view or add a comment, sign in
-
-
🚀 Understanding React Class Component Lifecycle In React, Class Components have a well-defined lifecycle — a sequence of methods that run during the component’s creation, update, and removal from the DOM. Knowing these lifecycle methods helps developers control how components behave and interact with data at each stage. 🔹 1. Mounting Phase – When the component is created and inserted into the DOM. ➡️ constructor() – Initializes state and binds methods. ➡️ render() – Returns JSX to display UI. ➡️ componentDidMount() – Invoked after the component mounts; ideal for API calls or setting up subscriptions. 🔹 2. Updating Phase – When props or state changes cause a re-render. ➡️ shouldComponentUpdate() – Decides if the component should re-render. ➡️ render() – Re-renders the updated UI. ➡️ componentDidUpdate() – Called after re-render; perfect for DOM updates or data fetching based on previous props/state. 🔹 3. Unmounting Phase – When the component is removed from the DOM. ➡️ componentWillUnmount() – Used to clean up (like removing event listeners or canceling API calls). 💡 Example: I recently implemented lifecycle methods in a project to fetch product data using componentDidMount() from a fake API(https://lnkd.in/gkFvXQV6) and dynamically display it on the UI. It helped me understand how React efficiently handles rendering and updates. 10000 Coders Meghana M #ReactJS #WebDevelopment #Frontend #Learning #ReactLifecycle #JavaScript #CodingJourney
To view or add a comment, sign in
-
Late-night React reflection 💻 Every time I write a small component, I’m reminded — learning React isn’t really about syntax. It’s about mindset — thinking in small, reusable, independent pieces that come together to build something bigger. Once that clicks, you stop writing UI… and start designing systems. 🚀 Here’s a small component I wrote tonight to keep that energy going. 💬 What’s one React concept that completely changed the way you think about building UIs? #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #ReactDeveloper #CodingMindset #LearnReact #100DaysOfCode
To view or add a comment, sign in
-
-
Understanding useEffect: React's Bridge Between Worlds 🌉 If you've ever wondered "what exactly is useEffect?", here's the big picture: At its core, useEffect is React's synchronization mechanism - the bridge that connects your component's pure rendering logic with the impure outside world. ────────────── 🎯 CORE CONCEPT ────────────── useEffect(() => { // This runs AFTER render // and synchronizes with external systems }, [dependencies]); // Re-run when these change ────────────── 🔍 KEY USAGE ────────────── External System Connections: // Browser APIs useEffect(() => { window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); NOT for Internal State: // ❌ Don't (use useMemo instead) useEffect(() => { setFullName(firstName + ' ' + lastName); }, [firstName, lastName]); ────────────── ✅ PROPER USES ────────────── • API data fetching • Browser event listeners • Subscription management • Third-party library integration ────────────── ❌ AVOID FOR ────────────── • Derived state (use useMemo) • Event handlers (use callbacks) • State transformations ────────────── 🎪 GOLDEN RULE ────────────── useEffect is your escape hatch from React's pure rendering world into the impure real world. Use it to sync with what's outside, not to manage what's inside. #ReactJS #JavaScript #WebDevelopment #Programming #SoftwareEngineering
To view or add a comment, sign in
-
🎲 Built a Random Number Generator using React Class Components! I'm exploring how state works in React and how components re-render dynamically. ⚡ What I learned today: 🔸 Updating state using setState 🔸 Generating dynamic values with Math.random() 🔸 Writing clean & structured class components 🔸 Styling components for a smooth UI ✨ ✨ Features: ✔ Generates a new random number instantly 🎰 ✔ Clean & simple UI ✔ Great practice for understanding React re-rendering Excited to continue improving and building more interactive components! 💻🔥 #ReactJS #Frontend #WebDevelopment #LearningJourney #JavaScript Meghana M 10000 Coders
To view or add a comment, sign in
-
🚀 I see this question a lot: "𝐖𝐡𝐚𝐭 𝐢𝐬 𝐭𝐡𝐞 𝐝𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐜𝐞 𝐛𝐞𝐭𝐰𝐞𝐞𝐧 𝐮𝐬𝐞𝐌𝐞𝐦𝐨 𝐚𝐧𝐝 𝐑𝐞𝐚𝐜𝐭.𝐦𝐞𝐦𝐨?" So here’s my simple explanation — the same way I would explain it in an interview 👇 🔹 1. React.memo — Prevents re-rendering of an entire component Think of React.memo as wrapping a component in a protective bubble. 👉 If the props didn’t change, the component won’t re-render. 👉 Useful for child components that receive the same props again and again. Example: const Child = React.memo(function Child({ count }) { console.log("Child Rendered"); return <p>Count: {count}</p>; }); ✔ React checks: “Did the props change?” ➡ If NO → skip re-render ➡ If YES → re-render ----------- 🔹 2. useMemo — Memoizes a value inside a component Think of useMemo as caching a calculation, not the component. 👉 It only recomputes a value when its dependencies change. 👉 Useful for expensive calculations, filtered lists, computed values, etc. Example: const filteredList = useMemo(() => { return items.filter(item => item.active); }, [items]); ✔ React checks: “Did items change?” ➡ If NO → return cached result ➡ If YES → recalculate 🎯 Simple Difference (One-Line Answer): 🔸 React.memo → Prevents re-render of a component 🔸 useMemo → Prevents re-calculation of a value #ReactJS #JavaScript #WebDevelopment #FrontendDevelopment #ReactTips #ReactHooks #FrontendEngineer #CodeNewbies #ProgrammingTips #WebDevCommunity
To view or add a comment, sign in
-
🚀 𝐖𝐡𝐲 𝐑𝐞𝐚𝐜𝐭 𝐌𝐨𝐯𝐞𝐝 𝐟𝐫𝐨𝐦 𝐂𝐥𝐚𝐬𝐬 𝐂𝐨𝐦𝐩𝐨𝐧𝐞𝐧𝐭𝐬 𝐭𝐨 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧 𝘙𝘦𝘢𝘤𝘵’𝘴 𝘴𝘩𝘪𝘧𝘵 𝘧𝘳𝘰𝘮 𝘤𝘭𝘢𝘴𝘴 𝘤𝘰𝘮𝘱𝘰𝘯𝘦𝘯𝘵𝘴 𝘵𝘰 𝘧𝘶𝘯𝘤𝘵𝘪𝘰𝘯 𝘤𝘰𝘮𝘱𝘰𝘯𝘦𝘯𝘵𝘴 𝘸𝘪𝘵𝘩 𝘏𝘰𝘰𝘬𝘴 𝘸𝘢𝘴𝘯’𝘵 𝘫𝘶𝘴𝘵 𝘢 𝘴𝘺𝘯𝘵𝘢𝘹 𝘶𝘱𝘨𝘳𝘢𝘥𝘦 — 𝘪𝘵 𝘤𝘰𝘮𝘱𝘭𝘦𝘵𝘦𝘭𝘺 𝘤𝘩𝘢𝘯𝘨𝘦𝘥 𝘩𝘰𝘸 𝘸𝘦 𝘸𝘳𝘪𝘵𝘦 𝘙𝘦𝘢𝘤𝘵 𝘢𝘱𝘱𝘴. Here’s why 👇 ✅ Simpler Syntax → Less boilerplate, cleaner and more readable code ✅ Hooks → Reusable and composable stateful logic ✅ No Lifecycle Confusion → Easier side-effect management with useEffect ✅ No this Keyword → Fewer bugs and clearer logic ✅ Better Performance → Easier for React to optimize renders ✅ Future-Ready → Designed for concurrent and server components React Hooks made components simpler, more powerful, and future-proof. #ReactJS #JavaScript #WebDevelopment #Frontend #ReactHooks #Coding
To view or add a comment, sign in
-
5 Common React Mistakes That Impact Performance (And How to Fix Them)⚠️ After reviewing hundreds of React codebases, these are the most common patterns that hurt performance and maintainability: 𝟭. 𝗡𝗼𝘁 𝗨𝘀𝗶𝗻𝗴 𝗞𝗲𝘆𝘀 𝗶𝗻 𝗟𝗶𝘀𝘁𝘀 Keys aren't optional; they're critical for React's reconciliation algorithm. Without unique keys, React can't efficiently determine which items changed, leading to unnecessary re-renders and potential state bugs. 𝟮. 𝗗𝗶𝗿𝗲𝗰𝘁𝗹𝘆 𝗠𝘂𝘁𝗮𝘁𝗶𝗻𝗴 𝗦𝘁𝗮𝘁𝗲 React's state is immutable by design. Mutations bypass React's change detection, resulting in components that don't update when they should. Always create new references with spread operators or immutable update patterns. 𝟯. 𝗜𝗴𝗻𝗼𝗿𝗶𝗻𝗴 𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁 𝗗𝗲𝗽𝗲𝗻𝗱𝗲𝗻𝗰𝘆 𝗪𝗮𝗿𝗻𝗶𝗻𝗴𝘀 ESLint's exhaustive-deps rule exists for a reason. Missing dependencies cause stale closures and race conditions that are incredibly difficult to debug in production. 𝟰. 𝗨𝘀𝗶𝗻𝗴 𝗔𝗿𝗿𝗮𝘆 𝗜𝗻𝗱𝗲𝘅 𝗮𝘀 𝗞𝗲𝘆 This works until your list reorders, at which point component state gets attached to the wrong items. The "it works in my testing" trap—until users encounter the edge case. 𝟱. 𝗙𝗼𝗿𝗴𝗲𝘁𝘁𝗶𝗻𝗴 𝘂𝘀𝗲𝗘𝗳𝗳𝗲𝗰𝘁 𝗖𝗹𝗲𝗮𝗻𝘂𝗽 Every subscription, timer, or event listener needs cleanup. Memory leaks accumulate silently until your app slows to a crawl after extended use. 💡 𝗞𝗲𝘆 𝗜𝗻𝘀𝗶𝗴𝗵𝘁: In my experience optimizing React applications, fixing these five patterns typically improves render performance by 30-50%. The React team built incredible tooling to catch these issues, use ESLint's React plugins and React DevTools Profiler. What React patterns do you see most often in code reviews? #ReactJS #JavaScript #WebDevelopment #SoftwareEngineering #FrontendDevelopment #PerformanceOptimization #CleanCode #BestPractices #Programming #FullStackDevelopment #CodeReview #ReactHooks #SoftwareDeveloper #TechTips
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
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