<?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>Forem: Ravindra Kumar</title>
    <description>The latest articles on Forem by Ravindra Kumar (@ravi-coding).</description>
    <link>https://forem.com/ravi-coding</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%2F2029228%2F040177cd-89a9-4e87-a3d2-36cea694274f.png</url>
      <title>Forem: Ravindra Kumar</title>
      <link>https://forem.com/ravi-coding</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ravi-coding"/>
    <language>en</language>
    <item>
      <title>AI Content Assistant with Role-Based Access Control (RBAC)</title>
      <dc:creator>Ravindra Kumar</dc:creator>
      <pubDate>Mon, 05 May 2025 09:10:34 +0000</pubDate>
      <link>https://forem.com/ravi-coding/ai-content-assistant-with-role-based-access-control-rbac-2b6m</link>
      <guid>https://forem.com/ravi-coding/ai-content-assistant-with-role-based-access-control-rbac-2b6m</guid>
      <description>&lt;p&gt;This is my submission for the &lt;strong&gt;[&lt;a href="https://Permit.io" rel="noopener noreferrer"&gt;https://Permit.io&lt;/a&gt; Dev Challenge]&lt;/strong&gt;&lt;br&gt;
   #permitio #devchallenge #rbac #javascript #webdev #ai&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 What I Built
&lt;/h2&gt;

&lt;p&gt;An &lt;strong&gt;AI-powered content assistant&lt;/strong&gt; where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users submit content for AI summarization.&lt;/li&gt;
&lt;li&gt;Admins can &lt;strong&gt;review, approve, reject, and publish&lt;/strong&gt; summaries.&lt;/li&gt;
&lt;li&gt;RBAC is handled using &lt;strong&gt;Permit.io&lt;/strong&gt; to ensure only authorized actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 &lt;strong&gt;AI Summary&lt;/strong&gt; is mocked due to API limits, but the RBAC and flows are fully functional!&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 The Problem It Solves
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;AI-generated content is powerful, but publishing it without review can lead to misinformation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This tool helps solve that by ensuring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users can use AI to generate drafts.&lt;/li&gt;
&lt;li&gt;Only &lt;strong&gt;approved roles (admins)&lt;/strong&gt; can publish or approve that content.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🌟 Demo
&lt;/h2&gt;

&lt;p&gt;🔗 Live App: [&lt;a href="https://ai-content-review-fjt8.vercel.app/" rel="noopener noreferrer"&gt;https://ai-content-review-fjt8.vercel.app/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;📁 GitHub Repo: &lt;a href="https://github.com/Ravi-Coding/permit-ai-content" rel="noopener noreferrer"&gt;https://github.com/Ravi-Coding/ai-content-review&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ How I Built It
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend&lt;/strong&gt;: React (Vite) + TypeScript + Tailwind CSS
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend&lt;/strong&gt;: Express.js + Node.js
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorization&lt;/strong&gt;: &lt;code&gt;@permit.io/sdk&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting&lt;/strong&gt;: Vercel (Frontend), Render (Backend)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Summary&lt;/strong&gt;: Mocked for now (can be extended using OpenAI)
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔐 RBAC with Permit.io
&lt;/h2&gt;

&lt;p&gt;Using &lt;code&gt;permit.check(user, action, resource)&lt;/code&gt; to validate access.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
ts
const allowed = await permit.check(user, "summarize", "content");
if (!allowed) {
  return res.status(403).json({ error: "Access Denied" });
}

## 🔐 Roles Defined

- **user**: Can submit content  
- **admin**: Can approve, delete, and publish  

---

## 🖥️ Dashboards Included

### User Dashboard:
- Submit content  
- View status  

### Admin Dashboard:
- View all submissions  
- Approve / Delete / Publish  

---

## 💡 Lessons &amp;amp; Challenges

- 🔄 Mocked AI summaries to simulate production AI logic  
- 🛡️ Implemented clean role-based permissions using Permit.io’s policy UI  
- ⚠️ Error handling and fallback logic to ensure seamless UX  

---

## 🙌 Special Thanks

Huge thanks to **Permit.io** for this opportunity and their powerful SDK + Policy Studio!

---

## 📌 Final Thoughts

Permit.io made it **incredibly easy** to manage permissions without hardcoding logic.  
This challenge helped me understand how secure AI tools can be built in real-world production.

Feel free to try it out and give feedback 🙏
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Multilingual AI Blog Generator | Hugging Face + Pulumi + S3 Static Hosting</title>
      <dc:creator>Ravindra Kumar</dc:creator>
      <pubDate>Mon, 07 Apr 2025 00:20:02 +0000</pubDate>
      <link>https://forem.com/ravi-coding/multilingual-ai-blog-generator-hugging-face-pulumi-s3-static-hosting-340d</link>
      <guid>https://forem.com/ravi-coding/multilingual-ai-blog-generator-hugging-face-pulumi-s3-static-hosting-340d</guid>
      <description>&lt;h1&gt;
  
  
  🌍 Multilingual AI Blog Generator — Pulumi Challenge Submission 🚀
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/pulumi"&gt;Pulumi Deploy and Document Challenge&lt;/a&gt;: Fast Static Website Deployment&lt;/em&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%2Foq21mkkk2q7ai0o3qj8r.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%2Foq21mkkk2q7ai0o3qj8r.png" alt="Multilingual AI Blog Generator Cover" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ What I Built
&lt;/h2&gt;

&lt;p&gt;I created a &lt;strong&gt;Multilingual AI Blog Generator&lt;/strong&gt;, a full-stack web app that uses Hugging Face models to generate blogs and translate them into multiple languages — promoting inclusive and accessible content creation.&lt;/p&gt;

&lt;p&gt;To meet the static deployment requirement of the Pulumi challenge, I built a &lt;strong&gt;visually engaging static landing page&lt;/strong&gt;, deployed using &lt;strong&gt;Pulumi + AWS S3&lt;/strong&gt;. This static page serves as the gateway to the full AI app hosted on Vercel.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌐 Live Demo
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;Static Landing Page (Pulumi + AWS S3):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://blog-static-bucket-4d15c3f.s3-website.ap-south-1.amazonaws.com" rel="noopener noreferrer"&gt;https://blog-static-bucket-4d15c3f.s3-website.ap-south-1.amazonaws.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🚀 &lt;strong&gt;Full AI App (Next.js + Hugging Face + Tailwind):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://multilingual-ai-blog.vercel.app" rel="noopener noreferrer"&gt;https://multilingual-ai-blog.vercel.app&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🌟 The static page loads instantly, and links you to the dynamic multilingual blog generator powered by AI.&lt;/p&gt;
&lt;/blockquote&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%2F2km1l3u4igu8jslw1x0w.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%2F2km1l3u4igu8jslw1x0w.png" alt="Static Landing Page Preview" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  📦 Project Repo
&lt;/h2&gt;

&lt;p&gt;🔗 &lt;strong&gt;GitHub Repository:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/Ravi-Coding/multilingual-ai-blog" rel="noopener noreferrer"&gt;https://github.com/Ravi-Coding/multilingual-ai-blog&lt;/a&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%2Fjkw2aax7k33isyrw2qng.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%2Fjkw2aax7k33isyrw2qng.png" alt="GitHub Project Structure" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🌱 My Journey
&lt;/h2&gt;

&lt;p&gt;This challenge allowed me to blend AI, frontend design, and DevOps deployment. Key highlights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Designed a clean and responsive UI with &lt;strong&gt;Next.js&lt;/strong&gt; + &lt;strong&gt;Tailwind CSS&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ Used &lt;strong&gt;Hugging Face Transformers&lt;/strong&gt; for multilingual blog generation&lt;/li&gt;
&lt;li&gt;✅ Built a static landing page for instant S3 loading using &lt;strong&gt;Pulumi&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;✅ Solved real-world IAM permission and bucket policy issues&lt;/li&gt;
&lt;li&gt;✅ Balanced &lt;strong&gt;static + dynamic&lt;/strong&gt; site architecture for scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 It was exciting to see the synergy between DevOps automation and AI application delivery — truly a full-stack experience!&lt;/p&gt;
&lt;/blockquote&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%2Fpaqth1ok5xdhi4mm45jj.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%2Fpaqth1ok5xdhi4mm45jj.png" alt="Terminal + Deployment Logs" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Using Pulumi
&lt;/h2&gt;

&lt;p&gt;Pulumi helped me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🚀 &lt;strong&gt;Provision an S3 bucket&lt;/strong&gt; for static hosting&lt;/li&gt;
&lt;li&gt;📂 Upload files (&lt;code&gt;index.html&lt;/code&gt;, images, favicon) automatically&lt;/li&gt;
&lt;li&gt;🔐 Setup a &lt;strong&gt;BucketPolicy&lt;/strong&gt; to enable public access&lt;/li&gt;
&lt;li&gt;🤖 Use &lt;strong&gt;Pulumi Copilot in VS Code&lt;/strong&gt; to:

&lt;ul&gt;
&lt;li&gt;Generate policy snippets&lt;/li&gt;
&lt;li&gt;Fix permission errors&lt;/li&gt;
&lt;li&gt;Speed up IAC development&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;🧠 Pulumi made it seamless to deploy infrastructure with real code. I didn’t just click buttons — I &lt;strong&gt;engineered&lt;/strong&gt; the cloud!&lt;/p&gt;
&lt;/blockquote&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%2Fell9fqmb32uzcvngel99.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%2Fell9fqmb32uzcvngel99.png" alt="Pulumi Infrastructure" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  🙌 Thank You
&lt;/h3&gt;

&lt;p&gt;This challenge was fun, challenging, and helped me grow. Grateful to Dev.to + Pulumi for the opportunity! 💙&lt;br&gt;&lt;br&gt;
Let’s build more together 🚀&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>pulumichallenge</category>
      <category>webdev</category>
      <category>cloud</category>
    </item>
    <item>
      <title>How to Build Your First Full-Stack MERN App: A Beginner’s Guide</title>
      <dc:creator>Ravindra Kumar</dc:creator>
      <pubDate>Sat, 25 Jan 2025 11:00:39 +0000</pubDate>
      <link>https://forem.com/ravi-coding/how-to-build-your-first-full-stack-mern-app-a-beginners-guide-1h8m</link>
      <guid>https://forem.com/ravi-coding/how-to-build-your-first-full-stack-mern-app-a-beginners-guide-1h8m</guid>
      <description>&lt;p&gt;&lt;strong&gt;Content:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;↪ If you're new to full-stack development, the MERN stack is one of the best ways to dive in. MERN stands for MongoDB, Express.js, React.js, and Node.js—a powerful stack for building modern web apps.&lt;/p&gt;

&lt;p&gt;In this guide, we’ll create a simple MERN app step-by-step. Whether you’re a beginner or just looking to sharpen your skills, you’ll learn the fundamentals of building a full-stack application. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting Up Your Development Environment&lt;/strong&gt;&lt;br&gt;
Before diving into the code, make sure you have the following installed:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1.Node.js and npm&lt;/em&gt;&lt;/strong&gt;: Download Here&lt;br&gt;
&lt;strong&gt;&lt;em&gt;2.MongoDB&lt;/em&gt;&lt;/strong&gt;: Install Locally or Use MongoDB Atlas&lt;br&gt;
&lt;strong&gt;&lt;em&gt;3.Code Editor&lt;/em&gt;&lt;/strong&gt;: VS Code is recommended (Download Here)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Initializing Your MERN Project&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Backend Setup:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;1.Create a new folder:&lt;/em&gt;&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;mkdir mern-app
cd mern-app

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. &lt;em&gt;Initialize a Node.js project:&lt;/em&gt;&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;npm init -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.&lt;em&gt;Install Express and Mongoose:&lt;/em&gt;&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;npm install express mongoose cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4.&lt;em&gt;Create a basic server in server.js:&lt;/em&gt;&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;const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');

const app = express();
app.use(cors());
app.use(express.json());

const PORT = 5000;
app.listen(PORT, () =&amp;gt; console.log(`Server running on http://localhost:${PORT}`));

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Frontend Setup:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1.&lt;em&gt;Navigate to your project folder and create a React app:&lt;/em&gt;&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;npx create-react-app client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.&lt;em&gt;Start the React app&lt;/em&gt;&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;cd client
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Building the MERN App&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;&lt;em&gt;Connect Frontend and Backend:&lt;/em&gt;&lt;/em&gt;&lt;br&gt;
↦ Set up a simple API in your backend to fetch and post data.&lt;br&gt;
↦ Use Axios in React to call your backend API.&lt;br&gt;
&lt;em&gt;&lt;em&gt;Example Axios Call in React:&lt;/em&gt;&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 axios from 'axios';

const fetchData = async () =&amp;gt; {
  const response = await axios.get('http://localhost:5000/api/data');
  console.log(response.data);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Deploy Your MERN App&lt;/strong&gt;&lt;br&gt;
↦ &lt;em&gt;Host your frontend on &lt;a href="https://vercel.com" rel="noopener noreferrer"&gt;Visit Vercel&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
↦ &lt;em&gt;Host your backend on &lt;a href="https://render.com" rel="noopener noreferrer"&gt;Host on Render&lt;/a&gt; or any platform of your choice.&lt;/em&gt;&lt;br&gt;
↦ &lt;em&gt;Use MongoDB Atlas for the database.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Congratulations! 🎉 You’ve just built your first full-stack MERN app. With the basics in place, you can now explore more features like authentication, state management, and advanced deployment techniques.&lt;/p&gt;

&lt;p&gt;Got questions or feedback? Drop a comment below or share your experience with building a MERN app!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>aws</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Why does my React useEffect hook run multiple times even with an empty dependency array?</title>
      <dc:creator>Ravindra Kumar</dc:creator>
      <pubDate>Sun, 08 Dec 2024 07:55:08 +0000</pubDate>
      <link>https://forem.com/ravi-coding/why-does-my-react-useeffect-hook-run-multiple-times-even-with-an-empty-dependency-array-5ea0</link>
      <guid>https://forem.com/ravi-coding/why-does-my-react-useeffect-hook-run-multiple-times-even-with-an-empty-dependency-array-5ea0</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Question&lt;/strong&gt;&lt;br&gt;
While working on a React project, I encountered an issue with the useEffect hook. My goal was to fetch data from an API only once when the component mounts. However, the useEffect kept running multiple times, even though I provided an empty dependency array.&lt;/p&gt;

&lt;p&gt;Here’s the code snippet:&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, { useEffect, useState } from "react";
import axios from "axios";

const MyComponent = () =&amp;gt; {
  const [data, setData] = useState([]);

  useEffect(() =&amp;gt; {
    console.log("Fetching data...");
    axios.get("https://jsonplaceholder.typicode.com/posts")
      .then(response =&amp;gt; setData(response.data))
      .catch(error =&amp;gt; console.error(error));
  }, []);
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Data&amp;lt;/h1&amp;gt;
      &amp;lt;ul&amp;gt;
        {data.map(item =&amp;gt; (
          &amp;lt;li key={item.id}&amp;gt;{item.name}&amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};
export default MyComponent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
                                                                          Despite the empty dependency array ([]), the useEffect was executed multiple times. I tried restarting the development server, but the issue persisted. After some research and troubleshooting, I identified the root cause and resolved it. &lt;br&gt;
                                                                                        &lt;strong&gt;The Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why This Happens&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Strict Mode in Development:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If your app is running in React's development mode with StrictMode enabled, React intentionally mounts and unmounts components multiple times. This is a development-only behavior meant to detect side effects that may cause issues.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Re-renders or Hot Module Replacement (HMR):&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;During development, changes in the code may trigger Hot Module Replacement, causing the component to re-render and useEffect to execute again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Fix or Handle This Behavior&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identify Strict Mode:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're using StrictMode, understand that this behavior happens only in development and won’t affect the production build. You can temporarily disable it by removing&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 ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(&amp;lt;App /&amp;gt;, document.getElementById("root"));  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
                                                               However,it’s better to leave it enabled and adapt your code to handle potential side effects gracefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Prevent Duplicate API Calls:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use a flag to ensure that the API call happens only once during the component’s lifecycle, even&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, { useEffect, useState, useRef } from "react";
import axios from "axios";

const MyComponent = () =&amp;gt; {
  const [data, setData] = useState([]);
  const isFetched = useRef(false);

  useEffect(() =&amp;gt; {
    if (isFetched.current) return;

    console.log("Fetching data...");
    axios.get("https://api.example.com/data")
      .then(response =&amp;gt; setData(response.data))
      .catch(error =&amp;gt; console.error(error));

    isFetched.current = true;
  }, []);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Data&amp;lt;/h1&amp;gt;
      &amp;lt;ul&amp;gt;
        {data.map(item =&amp;gt; (
          &amp;lt;li key={item.id}&amp;gt;{item.name}&amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};
export default MyComponent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using a useRef ensures that the API call happens only once, regardless of the additional renders caused by StrictMode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Key Takeaways&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
. React’s Strict Mode in development is intentional and safe to leave on.&lt;br&gt;
. Production builds won’t have this issue.                                                                                     . Use useRef or other techniques to manage side effects when necessary.&lt;br&gt;
Use useRef or other techniques to manage side effects when necessary.&lt;br&gt;
Production builds won’t have this issue.&lt;br&gt;
Use useRef or other techniques to manage side effects when necessary.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>reacthook</category>
    </item>
    <item>
      <title>How to Master the MERN Stack: A Guide for Full-Stack Developers</title>
      <dc:creator>Ravindra Kumar</dc:creator>
      <pubDate>Mon, 09 Sep 2024 19:21:54 +0000</pubDate>
      <link>https://forem.com/ravi-coding/how-to-master-the-mern-stack-a-guide-for-full-stack-developers-3o7b</link>
      <guid>https://forem.com/ravi-coding/how-to-master-the-mern-stack-a-guide-for-full-stack-developers-3o7b</guid>
      <description>&lt;p&gt;The MERN stack (MongoDB, Express.js, React.js, Node.js) has become one of the most popular technologies for full-stack web development. As a developer, learning the MERN stack can open up a world of opportunities and set you on the path to building powerful, dynamic web applications. Here's how you can master the MERN stack and take your full-stack development skills to the next level.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding the Core Components of the MERN Stack
Before jumping into code, it’s essential to understand what each component of the MERN stack does:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;MongoDB: A NoSQL database that stores data in JSON-like documents. It’s highly flexible and scalable, making it a popular choice for modern applications.&lt;br&gt;
Express.js: A lightweight framework for building web applications in Node.js. It provides a simple interface for creating routes, handling requests, and building APIs.&lt;br&gt;
&lt;em&gt;&lt;strong&gt;React.js:&lt;/strong&gt;&lt;/em&gt; A JavaScript library for building user interfaces. React allows you to create dynamic, component-based UIs that can handle large amounts of data efficiently.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Node.js:&lt;/em&gt;&lt;/strong&gt; A JavaScript runtime that allows you to run JavaScript on the server-side. It’s fast, efficient, and perfect for building scalable web applications.&lt;br&gt;
To master the MERN stack, you need to develop a deep understanding of how these technologies work together.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Start with the Backend&lt;/em&gt;&lt;/strong&gt; (Node.js and Express)
Begin by setting up your Node.js server. Start simple—create a basic API using Express.js to handle routes and requests. Focus on building RESTful APIs that can communicate with a database.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Learn how to create GET, POST, PUT, and DELETE routes.&lt;br&gt;
Connect your server to MongoDB using Mongoose.&lt;br&gt;
Understand error handling, middleware, and authentication (using JWT or OAuth).&lt;br&gt;
By mastering the backend, you will gain a solid understanding of how the data flows between the client and the server.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Build Dynamic UIs with React.js&lt;/strong&gt;
Once you’re comfortable with the backend, move on to the frontend. Learn React.js to create dynamic and responsive user interfaces.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understand the basics of components, props, and state.&lt;br&gt;
Practice using hooks like useState, useEffect, and useContext for managing state and side effects.&lt;br&gt;
Learn how to consume your backend APIs using fetch or Axios.&lt;br&gt;
React is at the core of the frontend development in the MERN stack, so take your time to understand component-based architecture and how it can help you build scalable applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Connecting the Dots: Full-Stack Integration&lt;/strong&gt;
Now that you have a good grasp of the frontend and backend, it’s time to integrate them. Focus on building full-stack applications where your React frontend interacts with the Express backend.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Implement CRUD functionality across your stack (e.g., create a simple task manager).&lt;br&gt;
Learn about state management libraries like Redux for handling complex states.&lt;br&gt;
Deploy your full-stack application using Heroku or Netlify.&lt;br&gt;
Understanding how the client and server communicate will enhance your ability to build feature-rich applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Tips for MERN Stack Beginners&lt;/strong&gt;
Practice Regularly: The more you practice, the better you’ll get. Start small and build simple projects, gradually increasing complexity.
Work on Real Projects: Apply what you’ve learned by building projects like a blog, e-commerce store, or task manager. Working on real projects will give you hands-on experience and a deeper understanding of how the stack works.
Learn Version Control: Using Git and GitHub will help you manage your projects and collaborate with other developers.
Stay Updated: The world of JavaScript is always evolving. Follow industry trends, and keep an eye on updates to React, Node, and MongoDB.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;&lt;strong&gt;Challenges You May Face&lt;/strong&gt;&lt;/em&gt;
Asynchronous Programming: Dealing with asynchronous code (using promises, async/await) can be tricky for beginners. Practice and learn how to handle async operations effectively.
State Management: Managing state in React can become complex as your application grows. Learn tools like Redux or the Context API for handling larger state structures.
Scaling Applications: As your app grows, performance and scalability become crucial. Learn about database indexing, caching, and optimizing your backend for performance.
Conclusion
Mastering the MERN stack is not just about learning each individual component—it's about understanding how they fit together to build scalable, performant web applications. Take your time, experiment, and don't be afraid to tackle real-world projects. The journey may seem challenging, but the rewards are well worth it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you have any questions or need further guidance, feel free to drop a comment. Happy coding!&lt;/p&gt;

</description>
      <category>mern</category>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>🚀 Excited to Share My Journey as a Full-Stack Developer!</title>
      <dc:creator>Ravindra Kumar</dc:creator>
      <pubDate>Thu, 05 Sep 2024 09:13:23 +0000</pubDate>
      <link>https://forem.com/ravi-coding/excited-to-share-my-journey-as-a-full-stack-developer-5f1f</link>
      <guid>https://forem.com/ravi-coding/excited-to-share-my-journey-as-a-full-stack-developer-5f1f</guid>
      <description>&lt;p&gt;Hello Dev.to community! 👋 I’m Ravindra, a passionate Full-Stack Developer with expertise in MERN (MongoDB, Express, React, Node.js) and Django. I’ve been diving deep into web development, building dynamic applications, and designing efficient APIs.&lt;/p&gt;

&lt;p&gt;Right now, I’m on an exciting new path exploring AWS and cloud technologies. 🌩️ From EC2 instances to S3 storage, I’m eager to expand my skills and integrate cloud solutions into my projects.&lt;/p&gt;

&lt;p&gt;In this space, I’ll be sharing insights on MERN and Django development, tutorials, and my journey with AWS. Stay tuned for posts on building scalable apps, deploying projects, and optimizing tech stacks!&lt;/p&gt;

&lt;p&gt;Looking forward to connecting with fellow developers, learning from each other, and collaborating on awesome projects. Feel free to reach out or share your thoughts and tips!&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>fullstackdeveloper</category>
      <category>mern</category>
      <category>django</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
