<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: kelseyroche</title>
    <description>The latest articles on DEV Community by kelseyroche (@kelseyroche).</description>
    <link>https://dev.to/kelseyroche</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2294101%2Fb1c34701-93a3-4459-9d7d-467c11bebb7a.jpg</url>
      <title>DEV Community: kelseyroche</title>
      <link>https://dev.to/kelseyroche</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kelseyroche"/>
    <language>en</language>
    <item>
      <title>React Day 2025 – Hot Takes, Deep Dives &amp; the Future of UI Engineering</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Tue, 29 Apr 2025 18:58:40 +0000</pubDate>
      <link>https://dev.to/kelseyroche/react-day-2025-hot-takes-deep-dives-the-future-of-ui-engineering-1219</link>
      <guid>https://dev.to/kelseyroche/react-day-2025-hot-takes-deep-dives-the-future-of-ui-engineering-1219</guid>
      <description>&lt;p&gt;React Day by Front End Nation delivered exactly what every React dev craves: unfiltered opinions, real-world insights, and a glimpse into the future of building for the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Kicking Off With Kent C. Dodds: AMA Style
&lt;/h2&gt;

&lt;p&gt;We opened the day with a live Ask Me Anything with Kent C. Dodds, creator of EpicReact.dev and one of the most influential voices in the React world. It was engaging, real, and packed with thought-provoking insights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most controversial opinion? The browser might not be the future. AI clients and MCP-like servers could take over.&lt;/li&gt;
&lt;li&gt;Biggest shift in mindset? Burnout is real. Slowing down can be the best move for sustainable impact.&lt;/li&gt;
&lt;li&gt;Favorite patterns? Composition over everything (compound components too!). &lt;/li&gt;
&lt;li&gt;Testing tools? He recommends Playwright over Cypress, Vite Test (V-test) over Jest, and skipping JSDOM entirely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Kent also touched on the React Compiler, advising caution unless you’re solving major performance challenges. For newbies moving from vanilla JS? His answer: start with the free resources at EpicReact.dev.&lt;/p&gt;

&lt;h2&gt;
  
  
  🎤 Top Talks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  💥 Maya Shavin – “We Are React-ing Wrongly”
&lt;/h3&gt;

&lt;p&gt;Think you’ve mastered React? Think again. Maya challenged us to let go of assumptions, dig deeper, and question how we use React daily—especially with the docs still evolving.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧠 Tejas Kumar – “UI Engineering for the AI Age”
&lt;/h3&gt;

&lt;p&gt;This wasn’t just futuristic fluff. Tejas walked us through how to design resilient UIs with streaming data, server components, and partial JSON handling—skills every dev will need as AI becomes more integral to front-end development.&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚡ Leah Thompson – “Using React with Inertia.js”
&lt;/h3&gt;

&lt;p&gt;Leah broke down Inertia 2.0 and showed how it brings speed to your frontend dev without sacrificing control. If you haven’t explored Inertia yet, now’s the time.&lt;/p&gt;

&lt;h3&gt;
  
  
  🦻 Shruti Kapoor – “Building Accessible Web Applications in React”
&lt;/h3&gt;

&lt;p&gt;Shruti made it clear: accessibility isn’t an afterthought. It’s a core part of quality development. Her talk included practical strategies and real-world examples to bake inclusion into your workflow from the start.&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The React ecosystem is evolving fast. Tools like Inertia.js and concepts like React Server Components are redefining what’s possible.&lt;/li&gt;
&lt;li&gt;AI will reshape our roles. We’ll soon be orchestrating logic, not just writing components.&lt;/li&gt;
&lt;li&gt;Accessibility and sustainability aren’t optional. They’re non-negotiable for modern development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;React Day wasn’t just a conference—it was a call to level up. Whether you’re just starting out or years deep into React, the future is here—and it’s time to build smarter, not just faster.&lt;/p&gt;

</description>
      <category>react</category>
      <category>ai</category>
      <category>frontend</category>
      <category>community</category>
    </item>
    <item>
      <title>Discover Your Dragon with the Threshing Quiz: A Journey into Coding and Fantasy</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Tue, 22 Apr 2025 20:39:20 +0000</pubDate>
      <link>https://dev.to/kelseyroche/discover-your-dragon-with-the-threshing-quiz-a-journey-into-coding-and-fantasy-1g7i</link>
      <guid>https://dev.to/kelseyroche/discover-your-dragon-with-the-threshing-quiz-a-journey-into-coding-and-fantasy-1g7i</guid>
      <description>&lt;p&gt;What do you get when you mix React, a dash of fantasy logic, and a whole lot of dragon energy? A custom personality quiz that tells you exactly what kind of dragon you’d bond with in the world of Fourth Wing.&lt;/p&gt;

&lt;p&gt;Let’s be real—if you’ve devoured Rebecca Yarros’ Fourth Wing, you’ve definitely wondered whether you’d survive the Rider’s Quadrant… and more importantly, which dragon would choose you. Clubtail or Scorpiontail? Fiery Red or fiercely loyal Brown? I needed answers. So, I built a quiz to find out.&lt;/p&gt;

&lt;p&gt;I wanted to create a “Which Dragon Would Bond With You?” quiz that didn’t just slap a label on you after a few shallow questions. I wanted this to feel immersive, a little chaotic (like any day in Navarre), and actually rooted in logic and personality mapping.&lt;/p&gt;

&lt;p&gt;Each answer choice ties to a series of traits—things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cunning, bold, empathetic, or ruthless&lt;/li&gt;
&lt;li&gt;Which then map to…&lt;/li&gt;
&lt;li&gt;Dragon colors and tail types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you answer all 15 questions, your most dominant traits determine your dragon bond. You get a final result like:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dragon Color: Black&lt;br&gt;
Tail Type: Scorpiontail&lt;br&gt;
(aka: you’re probably terrifying in the best possible way)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  ⚙️ The Tech Under The Talons
&lt;/h2&gt;

&lt;p&gt;This quiz was built using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React for building reusable components like QuestionCard and Result&lt;/li&gt;
&lt;li&gt;Framer Motion for animations that bring the questions to life with smooth transitions&lt;/li&gt;
&lt;li&gt;State management via useState to track current questions and accumulate trait data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At its core, each answer has an array of trait strings (e.g., ["intelligent", "cunning"]). Here’s how it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleAnswer = (traits) =&amp;gt; {
  setUserTraits((prev) =&amp;gt; [...prev, ...traits]);
  // move to the next question or show the result
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, when the quiz is over, we count how often each trait appears and map those to color and tail options:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const traitToColor = {
  loyal: ["Brown"],
  bold: ["Orange", "Red"],
  intelligent: ["Green", "Black"],
  // etc...
};

const traitToTail = {
  strong: "Clubtail",
  deadly: "Scorpiontail",
  bold: "Daggertail",
  // etc...
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, the calculateResult() function returns the most frequent match in each category to determine your dragon.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✨ Little UX Touches
&lt;/h2&gt;

&lt;p&gt;I added Framer Motion animations to each question card so it doesn’t just feel like flipping through a list. Instead, the quiz feels alive, like a mini Trial by Flame. Here’s the snippet that makes each transition buttery smooth:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;motion.div
  key={currentQuestionIndex}
  initial={{ opacity: 0, x: -100 }}
  animate={{ opacity: 1, x: 0 }}
  exit={{ opacity: 0, x: 100 }}
  transition={{ duration: 0.5 }}
&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🧪 What I Learned
&lt;/h2&gt;

&lt;p&gt;This project was more than just a fun fangirl moment—it pushed me to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structure complex decision logic based on user input&lt;/li&gt;
&lt;li&gt;Think modularly about UI and data flow&lt;/li&gt;
&lt;li&gt;Practice DOM animations in React with Framer Motion&lt;/li&gt;
&lt;li&gt;Design a dynamic, magical user experience with a whole lot of custom logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re curious about how I built this quiz or want to take it yourself to find your bonded dragon, check out the live site &lt;a href="https://fourth-wing-quiz.onrender.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;! And remember: some of us are meant for Gold dragons, others for poison-wielding Black ones. Either way, you better have the grit to back it up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;“Fly or die,” right?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>vite</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>A Beginner’s Guide to Drag-and-Drop with DnD Kit in React</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Mon, 24 Feb 2025 21:57:29 +0000</pubDate>
      <link>https://dev.to/kelseyroche/a-beginners-guide-to-drag-and-drop-with-dnd-kit-in-react-5hfe</link>
      <guid>https://dev.to/kelseyroche/a-beginners-guide-to-drag-and-drop-with-dnd-kit-in-react-5hfe</guid>
      <description>&lt;p&gt;Drag-and-drop functionality can enhance user interactions by allowing elements to be moved dynamically within a UI. In this guide, we'll explore how to implement drag-and-drop using &lt;strong&gt;&lt;a href="https://dndkit.com/" rel="noopener noreferrer"&gt;DnD Kit&lt;/a&gt;&lt;/strong&gt;, a lightweight and flexible React library.  &lt;/p&gt;

&lt;h2&gt;
  
  
  🏗 Why Use DnD Kit?
&lt;/h2&gt;

&lt;p&gt;DnD Kit offers:&lt;br&gt;&lt;br&gt;
✅ A modern, &lt;strong&gt;unopinionated&lt;/strong&gt; API for drag-and-drop.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Lightweight&lt;/strong&gt; (smaller than alternatives like react-beautiful-dnd).&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Keyboard support&lt;/strong&gt; for accessibility.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Customizable sensors&lt;/strong&gt; (mouse, touch, and keyboard).  &lt;/p&gt;

&lt;p&gt;Let's dive into the setup and implementation!  &lt;/p&gt;


&lt;h2&gt;
  
  
  🚀 Setting Up DnD Kit
&lt;/h2&gt;

&lt;p&gt;First, install DnD Kit:  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install @dnd-kit/core&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
or with Yarn:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;yarn add @dnd-kit/core&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  🛠 Basic Drag-and-Drop Example
&lt;/h2&gt;

&lt;p&gt;We’ll create a simple example where users can drag and drop items between two lists.&lt;/p&gt;
&lt;h3&gt;
  
  
  1️⃣ Setting Up the Context
&lt;/h3&gt;

&lt;p&gt;In DnD Kit, we wrap our app with a DndContext, which manages drag-and-drop events.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import React, { useState } from "react";
import { DndContext } from "@dnd-kit/core";

function App() {
  const [items, setItems] = useState(["Item 1", "Item 2", "Item 3"]);

  return (
    &amp;lt;DndContext&amp;gt;
      &amp;lt;div&amp;gt;
        {items.map((item, index) =&amp;gt; (
          &amp;lt;div key={index}&amp;gt;{item}&amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
    &amp;lt;/DndContext&amp;gt;
  );
}

export default App;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this stage, nothing is draggable yet. Next, we’ll make the items draggable.&lt;/p&gt;

&lt;h3&gt;
  
  
  2️⃣ Making Items Draggable
&lt;/h3&gt;

&lt;p&gt;To make items draggable, we use useDraggable from @dnd-kit/core.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import { useDraggable } from "@dnd-kit/core";

function DraggableItem({ id, children }) {
  const { attributes, listeners, setNodeRef, transform } = useDraggable({
    id,
  });

  const style = {
    transform: transform ? `translate(${transform.x}px, ${transform.y}px)` : undefined,
  };

  return (
    &amp;lt;div ref={setNodeRef} {...listeners} {...attributes} style={style}&amp;gt;
      {children}
    &amp;lt;/div&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, update App.js to use DraggableItem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&amp;lt;DndContext&amp;gt;
  {items.map((item, index) =&amp;gt; (
    &amp;lt;DraggableItem key={index} id={index}&amp;gt;
      {item}
    &amp;lt;/DraggableItem&amp;gt;
  ))}
&amp;lt;/DndContext&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, items can be dragged but not yet dropped!&lt;/p&gt;

&lt;h3&gt;
  
  
  3️⃣ Enabling Droppable Areas
&lt;/h3&gt;

&lt;p&gt;To allow items to be dropped, use the useDroppable hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import { useDroppable } from "@dnd-kit/core";

function DroppableArea({ id, children }) {
  const { setNodeRef } = useDroppable({ id });

  return (
    &amp;lt;div ref={setNodeRef} style={{ padding: 20, border: "2px dashed #ccc" }}&amp;gt;
      {children}
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wrap DraggableItem inside DroppableArea:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DndContext&amp;gt;
  &amp;lt;DroppableArea id="drop-zone"&amp;gt;
    {items.map((item, index) =&amp;gt; (
      &amp;lt;DraggableItem key={index} id={index}&amp;gt;
        {item}
      &amp;lt;/DraggableItem&amp;gt;
    ))}
  &amp;lt;/DroppableArea&amp;gt;
&amp;lt;/DndContext&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4️⃣ Handling Drag Events
&lt;/h3&gt;

&lt;p&gt;To update state when an item is dropped, use onDragEnd inside DndContext:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  const [items, setItems] = useState(["Item 1", "Item 2", "Item 3"]);

  function handleDragEnd(event) {
    const { active, over } = event;
    if (over &amp;amp;&amp;amp; active.id !== over.id) {
      setItems((prev) =&amp;gt; {
        const updatedItems = [...prev];
        const [movedItem] = updatedItems.splice(active.id, 1);
        updatedItems.splice(over.id, 0, movedItem);
        return updatedItems;
      });
    }
  }

  return (
    &amp;lt;DndContext onDragEnd={handleDragEnd}&amp;gt;
      &amp;lt;DroppableArea id="drop-zone"&amp;gt;
        {items.map((item, index) =&amp;gt; (
          &amp;lt;DraggableItem key={index} id={index}&amp;gt;
            {item}
          &amp;lt;/DraggableItem&amp;gt;
        ))}
      &amp;lt;/DroppableArea&amp;gt;
    &amp;lt;/DndContext&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when an item is dropped, the list updates dynamically! 🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  🎨 Styling the Drag Effect
&lt;/h3&gt;

&lt;p&gt;To enhance the UI, apply styles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.draggable {
  padding: 10px;
  margin: 5px;
  background: #f4f4f4;
  border-radius: 5px;
  cursor: grab;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🔥 Advanced Features to Explore
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;• Sorting Lists → @dnd-kit/sortable&lt;br&gt;
• Drag Constraints → Limit draggable areas&lt;br&gt;
• Custom Animations → Smooth transitions&lt;br&gt;
• Keyboard Accessibility → Improve usability&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  🏁 Wrapping Up&lt;br&gt;
&lt;/h3&gt;

&lt;p&gt;DnD Kit is a lightweight, flexible solution for adding drag-and-drop to React apps. By using DndContext, useDraggable, and useDroppable, you can create interactive and accessible interfaces with minimal effort.&lt;/p&gt;

&lt;p&gt;🚀 Try it out in your next project!&lt;/p&gt;

&lt;p&gt;💬 Have questions? Drop a comment below!&lt;/p&gt;

&lt;p&gt;💡 If you found this helpful, share it and follow me for more React content! 🚀&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Making Your CLI Applications Pop with Styled Outputs</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Fri, 10 Jan 2025 16:29:43 +0000</pubDate>
      <link>https://dev.to/kelseyroche/making-your-cli-applications-pop-with-styled-outputs-2dl6</link>
      <guid>https://dev.to/kelseyroche/making-your-cli-applications-pop-with-styled-outputs-2dl6</guid>
      <description>&lt;p&gt;Console apps don’t have to be boring! Sure, they’re often thought of as plain and functional, but adding a bit of color, bold text, and style can make a world of difference. With Python libraries like colorama and rich, it’s surprisingly easy to give your CLI tools some personality. Let’s check out how you can bring them to life!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Style Your CLI Outputs?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Improve Usability: Highlight important messages like errors or warnings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enhance Readability: Use color coding to organize output.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make It Fun: Add personality to your application with creative styling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  colorama
&lt;/h2&gt;

&lt;p&gt;colorama is a lightweight library that enables ANSI color codes on Windows and other platforms, making it a great choice for simple styling needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install colorama

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Basic Usage:&lt;/strong&gt;&lt;br&gt;
Here’s how to use colorama to style your console outputs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from colorama import Fore, Back, Style, init

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Initialize colorama&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;init()

print(Fore.RED + "This is red text")
print(Back.YELLOW + "This has a yellow background")
print(Style.BRIGHT + "This text is bold")
print(Style.RESET_ALL + "Back to normal style")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Red text&lt;/li&gt;
&lt;li&gt;Yellow background&lt;/li&gt;
&lt;li&gt;Bold text&lt;/li&gt;
&lt;li&gt;Reset to normal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use Case: Highlight error messages:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(Fore.RED + "Error: Invalid input!" + Style.RESET_ALL)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  rich
&lt;/h2&gt;

&lt;p&gt;If you want more advanced features, like tables, progress bars, and markdown support, rich is an excellent choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install rich

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Basic Styling:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from rich.console import Console

console = Console()

console.print("[bold magenta]Hello, World![/bold magenta]")
console.print("[red]Error:[/red] Something went wrong.")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bold magenta text&lt;/li&gt;
&lt;li&gt;Red text with “Error” label&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use Case: Formatting a table:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from rich.table import Table

table = Table(title="Sample Table")

table.add_column("Name", style="cyan")
table.add_column("Age", justify="right", style="green")
table.add_row("Alice", "30")
table.add_row("Bob", "25")

console.print(table)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Combining colorama and rich
&lt;/h2&gt;

&lt;p&gt;You can combine the simplicity of colorama for basic styling and the advanced features of rich to create a dynamic CLI experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from colorama import Fore, Style, init
from rich.console import Console
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Initialize colorama&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;init()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a rich console&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console = Console()

print(Fore.YELLOW + "Welcome to the Styled CLI App!" + Style.RESET_ALL)
console.print("[green]Let's get started![/green]")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tips for Effective CLI Styling&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Color Consistently: Assign specific colors to warnings, errors, and success messages.&lt;/li&gt;
&lt;li&gt;Don’t Overdo It: Too much color or bold text can overwhelm users.&lt;/li&gt;
&lt;li&gt;Test for Readability: Ensure your colors are readable on light and dark terminal themes.&lt;/li&gt;
&lt;li&gt;Provide a Plain Mode: Offer a way to disable styling for users who prefer plain text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Styling your CLI outputs can significantly enhance user experience, making your applications more functional and fun. Whether you use colorama for lightweight color support or rich for advanced formatting, Python makes it easy to create visually appealing console tools.&lt;/p&gt;

&lt;p&gt;Have you tried adding styles to your CLI apps? Let me know your experiences in the comments!&lt;/p&gt;

&lt;p&gt;Resources:&lt;br&gt;
&lt;a href="https://pypi.org/project/colorama/" rel="noopener noreferrer"&gt;https://pypi.org/project/colorama/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/introduction-to-python-colorama/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/introduction-to-python-colorama/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://rich.readthedocs.io/en/stable/introduction.html" rel="noopener noreferrer"&gt;https://rich.readthedocs.io/en/stable/introduction.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.geeksforgeeks.org/installing-and-using-rich-package-in-python/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/installing-and-using-rich-package-in-python/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cli</category>
      <category>python</category>
      <category>styling</category>
      <category>beginners</category>
    </item>
    <item>
      <title>6 Beginner Mistakes in Python and How To Fix Them</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Mon, 30 Dec 2024 17:10:46 +0000</pubDate>
      <link>https://dev.to/kelseyroche/6-beginner-mistakes-in-python-and-how-to-fix-them-1d15</link>
      <guid>https://dev.to/kelseyroche/6-beginner-mistakes-in-python-and-how-to-fix-them-1d15</guid>
      <description>&lt;h2&gt;
  
  
  1. Misusing Indentation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Mistake:&lt;/strong&gt;&lt;br&gt;
Python is strict about indentation, and early on, I accidentally mixed tabs and spaces in my code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
I configured my code editor to use spaces instead of tabs (4 spaces per indentation level). I also enabled a “show whitespace” option to catch accidental formatting errors early.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson Learned:&lt;/em&gt; Always be consistent with your indentation style.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Confusing Mutable and Immutable Data Types
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Mistake:&lt;/strong&gt;&lt;br&gt;
I tried to modify a tuple, only to get a TypeError. Later, I accidentally modified a list that I didn’t mean to, leading to unexpected behavior in my code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
I learned the distinction between mutable (e.g., lists, dictionaries) and immutable (e.g., tuples, strings) data types. When I needed to keep data unchanged, I started using tuples or frozenset.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson Learned:&lt;/em&gt; Understand the difference between mutable and immutable types to avoid unintended consequences.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Forgetting to Initialize Variables
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Mistake:&lt;/strong&gt;&lt;br&gt;
I attempted to use a variable before assigning it a value, which caused a NameError.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
To prevent this, I adopted a habit of initializing variables with default values when declaring them. For example:&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(total)  # NameError: name 'total' is not defined  

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;total = 0  
print(total)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Lesson Learned&lt;/em&gt;: Always initialize variables before using them.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Overwriting Built-In Function Names
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Mistake:&lt;/strong&gt;&lt;br&gt;
I named a variable list in one of my scripts, which overwrote Python’s built-in list function. This caused issues when I later tried to use list() to create a new list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
I became more mindful of variable names and avoided using names that clash with Python’s built-in functions. Tools like linters also helped me catch these mistakes before running the code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson Learned&lt;/em&gt;: Avoid using Python’s reserved words and built-in function names as variable names.&lt;/p&gt;
&lt;h2&gt;
  
  
  5. Not Using List Comprehensions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Mistake:&lt;/strong&gt;&lt;br&gt;
I used long, nested for loops to create new lists, which made my code harder to read and less efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
I learned about list comprehensions and started using them for concise and readable code. For example:&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;squared_numbers = []  
for num in range(10):  
    squared_numbers.append(num ** 2) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;squared_numbers = [num ** 2 for num in range(10)]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Lesson Learned&lt;/em&gt;: Embrace Pythonic constructs like list comprehensions for cleaner and faster code.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Not Using F-Strings for String Formatting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Mistake:&lt;/strong&gt;&lt;br&gt;
I used older string formatting methods like % or .format(), which were less readable and sometimes error-prone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Fix:&lt;/strong&gt;&lt;br&gt;
I switched to f-strings for cleaner and more intuitive formatting. For example:&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print("Hello, {}!".format(name))  

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(f"Hello, {name}!")  

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Lesson Learned&lt;/em&gt;: F-strings (introduced in Python 3.6) are a game-changer for readable and efficient string formatting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Mistakes are an essential part of learning, especially when it comes to programming. While these early missteps were frustrating, they helped me grow as a Python developer. If you’re just starting out, remember to embrace your mistakes—they’re stepping stones to success.&lt;/p&gt;

&lt;p&gt;What beginner mistakes have you made while coding? Share your experiences in the comments below!&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>coding</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>One-to-Many and Many-to-Many Relationships in Python with SQLite</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Sun, 29 Dec 2024 21:06:06 +0000</pubDate>
      <link>https://dev.to/kelseyroche/one-to-many-and-many-to-many-relationships-in-python-with-sqlite-3620</link>
      <guid>https://dev.to/kelseyroche/one-to-many-and-many-to-many-relationships-in-python-with-sqlite-3620</guid>
      <description>&lt;p&gt;When working with databases in Python, understanding relationships between tables is crucial. Two of the most common relationships you’ll encounter are one-to-many and many-to-many. Let’s use a WNBA example to explore what these relationships are, how they work in SQLite, and how to implement them using Python.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1dhcof0a8j7lwvoozg1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1dhcof0a8j7lwvoozg1.gif" alt=" " width="470" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are One-to-Many and Many-to-Many Relationships?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  One-to-Many
&lt;/h3&gt;

&lt;p&gt;A one-to-many relationship means that one record in a table is associated with multiple records in another table. For example, in a database of teams and athletes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One team can have many athletes.&lt;/li&gt;
&lt;li&gt;Each athlete belongs to only one team.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Many-to-Many
&lt;/h3&gt;

&lt;p&gt;A many-to-many relationship occurs when multiple records in one table are associated with multiple records in another table. For example, in a database of athletes and sponsorship deals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An athlete can have deals with many brands.&lt;/li&gt;
&lt;li&gt;A brand can have deals with many athletes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To implement many-to-many relationships in SQLite, you need a junction table (also known as a bridge or association table) to link the two main tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing Relationships in Python with SQLite
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setting Up the Database
&lt;/h3&gt;

&lt;p&gt;First, let’s create a database to demonstrate these relationships.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sqlite3

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Connect to the SQLite database (or create one if it doesn't exist)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conn = sqlite3.connect("sports.db")
cursor = conn.cursor()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create tables
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor.execute("""
CREATE TABLE IF NOT EXISTS Team (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL
)
""")

cursor.execute("""
CREATE TABLE IF NOT EXISTS Athlete (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    team_id INTEGER,
    FOREIGN KEY (team_id) REFERENCES Team (id)
)
""")

cursor.execute("""
CREATE TABLE IF NOT EXISTS Brand (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL
)
""")

cursor.execute("""
CREATE TABLE IF NOT EXISTS Deal (
    id INTEGER PRIMARY KEY,
    athlete_id INTEGER,
    brand_id INTEGER,
    FOREIGN KEY (athlete_id) REFERENCES Athlete (id),
    FOREIGN KEY (brand_id) REFERENCES Brand (id)
)
""")

conn.commit()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  One-to-Many: Teams and Athletes
&lt;/h2&gt;

&lt;p&gt;Let’s add data to demonstrate the one-to-many relationship between teams and athletes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Insert a team and athletes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor.execute("INSERT INTO Team (name) VALUES (?)", ("New York Liberty",))
team_id = cursor.lastrowid

cursor.execute("INSERT INTO Athlete (name, team_id) VALUES (?, ?)", ("Breanna Stewart", team_id))
cursor.execute("INSERT INTO Athlete (name, team_id) VALUES (?, ?)", ("Sabrina Ionescu", team_id))

conn.commit()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To query all athletes on a team:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor.execute("SELECT name FROM Athlete WHERE team_id = ?", (team_id,))
athletes = cursor.fetchall()
print("Athletes on the team:", athletes)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Many-to-Many: Athletes and Brands
&lt;/h2&gt;

&lt;p&gt;Now, let’s add data to demonstrate the many-to-many relationship between athletes and brands using the Deal table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Insert brands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor.execute("INSERT INTO Brand (name) VALUES (?)", ("Nike",))
brand_id_nike = cursor.lastrowid

cursor.execute("INSERT INTO Brand (name) VALUES (?)", ("Adidas",))
brand_id_adidas = cursor.lastrowid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Insert deals
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor.execute("INSERT INTO Deal (athlete_id, brand_id) VALUES (?, ?)", (1, brand_id_nike))
cursor.execute("INSERT INTO Deal (athlete_id, brand_id) VALUES (?, ?)", (1, brand_id_adidas))
cursor.execute("INSERT INTO Deal (athlete_id, brand_id) VALUES (?, ?)", (2, brand_id_nike))

conn.commit()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To query all brands associated with an athlete:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor.execute("""
SELECT Brand.name 
FROM Brand
JOIN Deal ON Brand.id = Deal.brand_id
WHERE Deal.athlete_id = ?
""", (1,))
brands = cursor.fetchall()
print("Brands for Athlete 1:", brands)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By defining relationships with foreign keys in SQLite and using Python to manage data, you can create robust databases with clear connections between tables. Understanding one-to-many and many-to-many relationships is essential for structuring data effectively.&lt;/p&gt;

&lt;p&gt;This simple example scratches the surface, but you can expand it to handle more complex relationships.&lt;/p&gt;

</description>
      <category>python</category>
      <category>sql</category>
      <category>beginners</category>
      <category>backend</category>
    </item>
    <item>
      <title>Theming with Styled-Components</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Fri, 06 Dec 2024 16:21:34 +0000</pubDate>
      <link>https://dev.to/kelseyroche/theming-with-styled-components-40nc</link>
      <guid>https://dev.to/kelseyroche/theming-with-styled-components-40nc</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;You know that satisfying feeling when you switch an app to dark mode and it just works? Theming does that—it makes things feel personal and polished. And the good news? Adding themes to your React app is way easier than you think, thanks to styled-components. In this post, I’ll show you how to use the ThemeProvider to set up light and dark themes so your app looks great no matter what your users prefer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2e9anek8auxp57ib2tn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2e9anek8auxp57ib2tn.gif" alt="dark mode light mode gif" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Theming Matters:
&lt;/h2&gt;

&lt;p&gt;Theming is more than just making things look nice. For some people, dark mode helps with eye strain, while others love the clean, bright feel of light mode. It’s all about giving your users options and showing you care about their experience. Plus, let’s be real—apps with themes just feel more modern and professional.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Styled-Components for Theming:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Install styled-components:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;npm install styled-components&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a Theme Object:&lt;/strong&gt;&lt;br&gt;
Define light and dark themes in a theme.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
export const lightTheme = {
    background: '#ffffff',
    color: '#000000',
};

export const darkTheme = {
    background: '#000000',
    color: '#ffffff',
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set Up the ThemeProvider:&lt;/strong&gt;&lt;br&gt;
Wrap your application in the ThemeProvider and pass the theme as a prop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ThemeProvider } from 'styled-components';
import { lightTheme, darkTheme } from './theme';

function App() {
    const [isDarkMode, setIsDarkMode] = useState(false);

    return (
        &amp;lt;ThemeProvider theme={isDarkMode ? darkTheme : lightTheme}&amp;gt;
            &amp;lt;button onClick={() =&amp;gt; setIsDarkMode(!isDarkMode)}&amp;gt;
                Toggle Theme
            &amp;lt;/button&amp;gt;
            &amp;lt;YourAppComponents /&amp;gt;
        &amp;lt;/ThemeProvider&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Access Theme Properties:&lt;/strong&gt;&lt;br&gt;
Use the props.theme object in your styled-components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import styled from 'styled-components';

const Container = styled.div`
    background-color: ${(props) =&amp;gt; props.theme.background};
    color: ${(props) =&amp;gt; props.theme.color};
`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;And that’s it—your app now has themes! With styled-components and ThemeProvider, you can quickly set up dynamic theming without breaking a sweat. It’s a small change that makes a big difference to your users. So go ahead, try it out, and give your app that extra bit of love. Who doesn’t like a good dark mode, anyway?&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://mui.com/material-ui/customization/theming/" rel="noopener noreferrer"&gt;https://mui.com/material-ui/customization/theming/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>themes</category>
    </item>
    <item>
      <title>Step-by-Step Guide: Parent/Child Components and Lifting State</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Fri, 22 Nov 2024 21:13:55 +0000</pubDate>
      <link>https://dev.to/kelseyroche/step-by-step-guide-parentchild-components-and-lifting-state-17ei</link>
      <guid>https://dev.to/kelseyroche/step-by-step-guide-parentchild-components-and-lifting-state-17ei</guid>
      <description>&lt;p&gt;In React, components often need to share information. To do this, we use parent/child relationships and sometimes need to “lift state” so components can communicate effectively. Here’s a simple guide to get you started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Parent-to-Child Communication: Pass data using props.&lt;/li&gt;
&lt;li&gt;Child-to-Parent Communication: Use functions passed as props to update the parent’s state.&lt;/li&gt;
&lt;li&gt;Lifting State: Move state to the nearest common parent to share it between sibling components.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  1. Parent and Child Components
&lt;/h2&gt;

&lt;p&gt;Think of a parent component and child components quite literally as a parent and their children. The parent manages the house and passes chores down to the children.&lt;/p&gt;

&lt;p&gt;Let’s create two components: Parent and Child. The parent will pass data to the child using props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parent Component:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import Child from './Child';

function Parent() {
  const message = "Hello from Parent!";

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Parent Component&amp;lt;/h1&amp;gt;
      &amp;lt;Child message={message} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Parent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;What do you think is the prop we will pass down to the Child?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Child Component:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

function Child({ message }) {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;Child Component&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;{message}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Child;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you render Parent, the child will display:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Hello from Parent!&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Lifting State Up
&lt;/h2&gt;

&lt;p&gt;Sometimes, a child component needs to send data back to its parent. This is where we “lift state.”&lt;/p&gt;

&lt;p&gt;Here’s an example where the child sends a message to the parent:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parent Component:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';
import Child from './Child';

function Parent() {
  const [childMessage, setChildMessage] = useState("");

  const handleMessage = (message) =&amp;gt; {
    setChildMessage(message);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Parent Component&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Message from Child: {childMessage}&amp;lt;/p&amp;gt;
      &amp;lt;Child onSendMessage={handleMessage} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Parent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Child Component:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;What props do you think we will be passing down to the Child function?&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import React from 'react';

function Child({ onSendMessage }) {
  const sendMessageToParent = () =&amp;gt; {
    onSendMessage("Hello from Child!");
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;Child Component&amp;lt;/h2&amp;gt;
      &amp;lt;button onClick={sendMessageToParent}&amp;gt;Send Message to Parent&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Child;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when you click the button in the child component, the parent updates its state and displays:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Message from Child: Hello from Child!&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Why Lift State?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If two child components need to share data, the parent can manage the state and pass it to both children.&lt;/li&gt;
&lt;li&gt;It avoids redundant state logic across components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example: Sibling Communication&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';
import ChildOne from './ChildOne';
import ChildTwo from './ChildTwo';

function Parent ()  {
  const [sharedState, setSharedState] = useState("");

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Parent Component&amp;lt;/h1&amp;gt;
      &amp;lt;ChildOne setSharedState={setSharedState} /&amp;gt;
      &amp;lt;ChildTwo sharedState={sharedState} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default Parent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ChildOne Component:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

function ChildOne ({ setSharedState }) {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;Child One&amp;lt;/h2&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setSharedState("Message from Child One")}&amp;gt;
        Send to Child Two
      &amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default ChildOne;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ChildTwo Component:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

function ChildTwo ({ sharedState }) {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h2&amp;gt;Child Two&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;{sharedState}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default ChildTwo;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When ChildOne sends a message, ChildTwo automatically receives it via the parent.&lt;/p&gt;

</description>
      <category>react</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Reactify Your Resume! Build a Basic Online Portfolio in React</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Wed, 20 Nov 2024 15:47:03 +0000</pubDate>
      <link>https://dev.to/kelseyroche/reactify-your-resume-build-a-basic-online-portfolio-in-react-59al</link>
      <guid>https://dev.to/kelseyroche/reactify-your-resume-build-a-basic-online-portfolio-in-react-59al</guid>
      <description>&lt;p&gt;Having a personal portfolio is essential in today’s job market, especially in tech. With React, you can create a dynamic and professional online portfolio that showcases your skills, projects, and personality. This guide will walk you through building a simple portfolio site step by step. In the future I will post a walkthrough for something a little more advanced, but this tutorial is great for beginners!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Set Up React
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make sure Node.js is installed. If not, download it from Node.js official site.&lt;br&gt;
Create a React Project with Vite:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run:&lt;br&gt;
&lt;code&gt;npm create vite@latest my-portfolio --template react&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Navigate to Your Project Folder:&lt;br&gt;
&lt;code&gt;cd my-portfolio&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Dependencies:&lt;br&gt;
&lt;code&gt;npm install&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start the Development Server:&lt;br&gt;
&lt;code&gt;npm start&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. Plan Your Portfolio Layout
&lt;/h2&gt;

&lt;p&gt;Think about the sections you want:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Header: Your name, a tagline, and navigation links.&lt;/li&gt;
&lt;li&gt;About: A short bio and your skills.&lt;/li&gt;
&lt;li&gt;Projects: A showcase of your work.&lt;/li&gt;
&lt;li&gt;Contact: Links to email and social media.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s an example of the folder structure for components:&lt;/p&gt;

&lt;p&gt;src/&lt;br&gt;
── components/&lt;br&gt;
|     ── App.js&lt;br&gt;
|     ── Header.js&lt;br&gt;
|     ── About.js&lt;br&gt;
|     ── Projects.js&lt;br&gt;
|     ── Contact.js&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Build Your Components
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Header Component&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create Header.js for your navigation and name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Header = () =&amp;gt; {
  return (
    &amp;lt;header&amp;gt;
      &amp;lt;h1&amp;gt;Your Name&amp;lt;/h1&amp;gt;
      &amp;lt;nav&amp;gt;
        &amp;lt;a href="#about"&amp;gt;About&amp;lt;/a&amp;gt;
        &amp;lt;a href="#projects"&amp;gt;Projects&amp;lt;/a&amp;gt;
        &amp;lt;a href="#contact"&amp;gt;Contact&amp;lt;/a&amp;gt;
      &amp;lt;/nav&amp;gt;
    &amp;lt;/header&amp;gt;
  );
};

export default Header;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;About Component&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Write your bio and skills in About.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const About = () =&amp;gt; {
  return (
    &amp;lt;section id="about"&amp;gt;
      &amp;lt;h2&amp;gt;About Me&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;Hi, I’m [Your Name], a budding software developer with a passion for [your interests].&amp;lt;/p&amp;gt;
      &amp;lt;h3&amp;gt;Skills:&amp;lt;/h3&amp;gt;
      &amp;lt;ul&amp;gt;
        &amp;lt;li&amp;gt;JavaScript&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;React&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;CSS&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;Node.js&amp;lt;/li&amp;gt;
      &amp;lt;/ul&amp;gt;
    &amp;lt;/section&amp;gt;
  );
};

export default About;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Projects Component&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Showcase your work in Projects.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Projects = () =&amp;gt; {
  const projectList = [
    { name: "Project 1", link: "https://github.com/yourproject1" },
    { name: "Project 2", link: "https://github.com/yourproject2" },
  ];

  return (
    &amp;lt;section id="projects"&amp;gt;
      &amp;lt;h2&amp;gt;My Projects&amp;lt;/h2&amp;gt;
      &amp;lt;ul&amp;gt;
        {projectList.map((project, index) =&amp;gt; (
          &amp;lt;li key={index}&amp;gt;
            &amp;lt;a href={project.link}&amp;gt;
              {project.name}
            &amp;lt;/a&amp;gt;
          &amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/section&amp;gt;
  );
};

export default Projects;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Contact Component&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Provide contact options in Contact.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const Contact = () =&amp;gt; {
  return (
    &amp;lt;section id="contact"&amp;gt;
      &amp;lt;h2&amp;gt;Contact Me&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;Email: &amp;lt;a href="mailto:youremail@example.com"&amp;gt;youremail@example.com&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;
        Find me on: 
        &amp;lt;a href="https://linkedin.com/in/yourprofile"&amp;gt;LinkedIn&amp;lt;/a&amp;gt; | 
        &amp;lt;a href="https://github.com/yourgithub"&amp;gt;GitHub&amp;lt;/a&amp;gt;
      &amp;lt;/p&amp;gt;
    &amp;lt;/section&amp;gt;
  );
};

export default Contact;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Assemble Your Portfolio in App.js
&lt;/h2&gt;

&lt;p&gt;Import and organize your components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import Header from './Header';
import About from './About';
import Projects from './Projects';
import Contact from './Contact';

function App() {
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;Header /&amp;gt;
      &amp;lt;main&amp;gt;
        &amp;lt;About /&amp;gt;
        &amp;lt;Projects /&amp;gt;
        &amp;lt;Contact /&amp;gt;
      &amp;lt;/main&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Style Your Portfolio and Deploy!
&lt;/h2&gt;

&lt;p&gt;Stay tuned, I am planning to write another blog post about CSS styling and launching your website via GitHub.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Would you like to see this project’s code in a GitHub repository? Let me know!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>react</category>
      <category>portfolio</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Creating My Pokémon Collection App: Local Data, Interactivity, and JavaScript Events</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Thu, 14 Nov 2024 20:00:11 +0000</pubDate>
      <link>https://dev.to/kelseyroche/creating-my-pokemon-collection-app-local-data-interactivity-and-javascript-events-4iga</link>
      <guid>https://dev.to/kelseyroche/creating-my-pokemon-collection-app-local-data-interactivity-and-javascript-events-4iga</guid>
      <description>&lt;h4&gt;
  
  
  Introduction
&lt;/h4&gt;

&lt;p&gt;When I started this project, my goal was simple: to create a Pokémon collection app where users could explore Pokémon and their details. By combining JavaScript, Node.js, and local data, I built an interactive app that allows users to view Pokémon images, abilities, and types—all while refining my skills with event listeners, dynamic content updates, and more. While I worked on this with a partner, I am going to focus on my work specifically. Here’s how it came together!&lt;/p&gt;




&lt;h4&gt;
  
  
  Project Overview
&lt;/h4&gt;

&lt;p&gt;This app is designed to showcase a collection of Pokémon images and stats, making it easy for users to click on each Pokémon to view details and switch between main and alternate images with hover interactions. I served the Pokémon data locally, which allowed me to focus on how to render, update, and interact with the data within the app itself.&lt;/p&gt;




&lt;h4&gt;
  
  
  Setting Up Local Data with &lt;code&gt;db.json&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Instead of pulling from an external API, I created a local &lt;code&gt;db.json&lt;/code&gt; file with Pokémon data, including attributes like name, type, ability, and image paths. Running a local server on &lt;code&gt;http://localhost:3500/pokemon&lt;/code&gt;, I could fetch this data using the &lt;code&gt;fetch&lt;/code&gt; method in JavaScript. The simplified setup allowed me to build and test the app entirely offline.&lt;/p&gt;




&lt;h4&gt;
  
  
  Code Walkthrough
&lt;/h4&gt;

&lt;p&gt;Here’s a look at how I approached key parts of the project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Fetching Data&lt;/strong&gt;:
The first step was to fetch Pokémon data from the local server. I created a &lt;code&gt;getAllPokemon&lt;/code&gt; function to handle the fetch request and return the Pokémon details in JSON format.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getAllPokemon&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pokemonURL&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function pulls in the Pokémon data from &lt;code&gt;http://localhost:3500/pokemon&lt;/code&gt;, which I then use to dynamically render each Pokémon.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Displaying Pokémon&lt;/strong&gt;:
To populate the collection, I used a &lt;code&gt;displayPokemons&lt;/code&gt; function that iterates through the fetched Pokémon data and renders each item as an image. I also added a &lt;code&gt;click&lt;/code&gt; event listener on each image, which opens up the Pokémon details when selected:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;displayPokemons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nf"&gt;getAllPokemon&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pokemonArr&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nx"&gt;pokemonArr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;renderPokemon&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="nf"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pokemonArr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// Display first Pokémon by default&lt;/span&gt;
     &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;renderPokemon&lt;/code&gt; function creates an image for each Pokémon, adds styling, and attaches a click event to display details.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Event Listeners: Adding Interactivity&lt;/strong&gt;
I used two main types of event listeners in this project: a form &lt;code&gt;submit&lt;/code&gt; listener for adding new Pokémon and &lt;code&gt;mouseover&lt;/code&gt;/&lt;code&gt;mouseout&lt;/code&gt; events to toggle between images. These listeners made the app more engaging and user-friendly.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Form Submission&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
 To add a new Pokémon, I set up a &lt;code&gt;submit&lt;/code&gt; listener on the form, which gathers values from input fields and adds the new Pokémon to the collection. This new Pokémon is rendered without needing to refresh the page:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;pokemonForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newPokemon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="na"&gt;ability&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ability&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="na"&gt;altImage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;altImage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;};&lt;/span&gt;
   &lt;span class="nf"&gt;renderPokemon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newPokemon&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Here, &lt;code&gt;event.preventDefault()&lt;/code&gt; stops the form from reloading the page, ensuring a smooth user experience.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Mouseover Event for Alternate Images&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
 When users hover over the Pokémon’s image in the details section, it switches to an alternate image, simulating an evolution or transformation. The &lt;code&gt;mouseover&lt;/code&gt; event triggers this switch, while &lt;code&gt;mouseout&lt;/code&gt; reverts it back:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;detailImage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;el&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;detail-image&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;detailImage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nf"&gt;el&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;detail-name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nf"&gt;el&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;detail-type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nf"&gt;el&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;detail-ability&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ability&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="nx"&gt;detailImage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mouseover&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;detailImage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;altImage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
   &lt;span class="nx"&gt;detailImage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mouseout&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;detailImage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pokemon&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;});&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This effect gives users a fun way to interact with each Pokémon and visually explore its characteristics.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Challenges and Learning Points
&lt;/h4&gt;

&lt;p&gt;One challenge was structuring the JavaScript to keep it modular and manageable, as event listeners and dynamic elements can quickly become hard to track. I learned to compartmentalize my code into smaller functions and to use event listeners selectively to optimize performance and readability.&lt;/p&gt;




&lt;h4&gt;
  
  
  Wrapping Up
&lt;/h4&gt;

&lt;p&gt;This Pokémon collection project was an exciting way to apply JavaScript, experiment with local data fetching, and add engaging event-driven interactivity. Building this app from scratch gave me valuable experience with both front-end and back-end concepts, leaving me inspired to explore more interactive projects in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check out my project on GitHub!:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/kelseyroche/phase-1-project-pokemon" rel="noopener noreferrer"&gt;https://github.com/kelseyroche/phase-1-project-pokemon&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>pokemon</category>
      <category>beginners</category>
      <category>jsonserver</category>
    </item>
    <item>
      <title>Callback Functions</title>
      <dc:creator>kelseyroche</dc:creator>
      <pubDate>Wed, 30 Oct 2024 16:54:39 +0000</pubDate>
      <link>https://dev.to/kelseyroche/callback-functions-lbi</link>
      <guid>https://dev.to/kelseyroche/callback-functions-lbi</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl83baagfss6kwfejk63u.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl83baagfss6kwfejk63u.gif" alt="Sharpay Callbacks gif" width="400" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Is learning about callback functions making you feel just like Sharpay?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well, before we get into the technical stuff let's think about it in a more theoretical way: with cake! 🎂&lt;/p&gt;

&lt;p&gt;Imagine you want to bake a cake for your friend's birthday. The day before their birthday you follow a recipe for the icing and put it in the fridge to sit overnight. &lt;em&gt;Here, the recipe for the icing is the callback function&lt;/em&gt;. You're not using the icing yet, but it's waiting to be called on later!&lt;/p&gt;

&lt;p&gt;The day of the birthday party you decide to pull up the cake recipe. It calls for flour, water, eggs, sugar, baking powder, salt, milk, &lt;em&gt;and icing&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;This recipe, or function, is using a bunch of variables and also that recipe, or function, for icing. It's calling back on that recipe you already created, or declared, earlier.&lt;/p&gt;

&lt;p&gt;Ok enough about cake (sadly), let's get into the technical stuff:&lt;/p&gt;

&lt;p&gt;At this point we are used to passing variables as arguments in a function. &lt;strong&gt;In Javascript, we can also use functions to pass as arguments in a new function.&lt;/strong&gt; The first function is the callback function and that is the one being passed as an argument through the new function.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;//callback function&lt;br&gt;
function icing ( ) {&lt;br&gt;
  console.log("vanilla icing")&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;//new function&lt;br&gt;
function cake (flavor, callback) {&lt;br&gt;
  console.log("My cake flavor is " + flavor);&lt;br&gt;
  callback();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;//using the callback function as an argument&lt;br&gt;
cake ("pumpkin", icing);&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do you think the result is here?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the bottom of the code you can see that we called the cake function. Because we are passing through "pumpkin" as the first argument, we know that the console is going to log "My cake flavor is pumpkin"&lt;/p&gt;

&lt;p&gt;The second part of this function uses the second parameter to call that function. When we are calling cake, we see that the second parameter we are calling is the icing function. The icing function wants us to console.log "vanilla icing."&lt;/p&gt;

&lt;p&gt;Therefore, our console should read:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;My cake flavor is pumpkin&lt;br&gt;
vanilla icing&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And there is our recipe for the callback function, enjoy!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff51w69yx0dn1m5xdzrcr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff51w69yx0dn1m5xdzrcr.png" alt="Cake with code on it in icing" width="800" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra Challenge:&lt;/strong&gt;&lt;br&gt;
Try writing a function called decorate that takes a callback function to add decorations to a cake!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other Materials&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.programiz.com/javascript/callback" rel="noopener noreferrer"&gt;https://www.programiz.com/javascript/callback&lt;/a&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Callback_function" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Glossary/Callback_function&lt;/a&gt;&lt;/p&gt;

</description>
      <category>callbackfunctions</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>explainlikeimfive</category>
    </item>
  </channel>
</rss>
