<?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: Sharanappa</title>
    <description>The latest articles on DEV Community by Sharanappa (@sharanappa_m).</description>
    <link>https://dev.to/sharanappa_m</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%2F2540765%2F2c9f023e-6fb8-4590-9b32-3e6c5fcbb395.jpeg</url>
      <title>DEV Community: Sharanappa</title>
      <link>https://dev.to/sharanappa_m</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sharanappa_m"/>
    <language>en</language>
    <item>
      <title>Deploying a Node.js Project with MySQL on Railway</title>
      <dc:creator>Sharanappa</dc:creator>
      <pubDate>Sat, 19 Apr 2025 20:23:10 +0000</pubDate>
      <link>https://dev.to/sharanappa_m/deploying-a-nodejs-project-with-mysql-on-railway-2k7n</link>
      <guid>https://dev.to/sharanappa_m/deploying-a-nodejs-project-with-mysql-on-railway-2k7n</guid>
      <description>&lt;h2&gt;
  
  
  1. Create a Railway Account &amp;amp; Log In via GitHub
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Railway website.&lt;/li&gt;
&lt;li&gt;Create an account or log in using your GitHub credentials.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Deploy a New Project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;After logging in, click on “Deploy a New Project”.&lt;/li&gt;
&lt;li&gt;Choose MySQL as the first service you want to deploy. Select the MySQL image.&lt;/li&gt;
&lt;li&gt;Once the MySQL container starts, you’ll see an option at the top-right corner of the page to configure your server.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Configure the Server with GitHub Repository
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Railway will ask you “What do you need?”&lt;/li&gt;
&lt;li&gt;Select GitHub repo to link your project from GitHub.&lt;/li&gt;
&lt;li&gt;Click on Configure GitHub App, and it will show you your repositories.&lt;/li&gt;
&lt;li&gt;Choose the repo that you want to deploy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Wait for 2 minutes for Railway to configure your project. After the configuration is done, you will be able to see your repo name in the server image list. Click on it to continue.
&lt;/h6&gt;

&lt;h2&gt;
  
  
  4. Deployment and Configuration
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;After clicking the repo name, Railway will open a window with different menus:&lt;/p&gt;
&lt;h6&gt;
  
  
  Deployments - Variables - Metrics - Settings
&lt;/h6&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Under Deployments, you’ll see logs showing the deployment status and success/failure messages.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Set Up MySQL Variables
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Under the Variables section, add the following environment variables for MySQL:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;MYSQLDATABASE&lt;/code&gt;&lt;br&gt;
&lt;code&gt;MYSQLHOST&lt;/code&gt;&lt;br&gt;
&lt;code&gt;MYSQLPASSWORD&lt;/code&gt;&lt;br&gt;
&lt;code&gt;MYSQLPORT&lt;/code&gt;&lt;br&gt;
&lt;code&gt;MYSQLUSER&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure these variables match the ones generated by Railway for your MySQL service.&lt;/li&gt;
&lt;/ul&gt;

&lt;h6&gt;
  
  
  Note: After adding the variables, Railway will automatically connect to MySQL. If it needs to create tables or connect, the server code will handle it.
&lt;/h6&gt;

&lt;h2&gt;
  
  
  6. Fixing Common Errors
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Root Directory Issue: If you’re working with multiple projects (e.g., client and server), Railway may prompt you to specify the correct root directory for your server. If you have two directories, ensure that the server directory is set as the root directory in the settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. Get Your Custom Domain
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the Settings tab, you’ll see an option for Networking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on Generate Domain to get your custom domain name for the deployed service.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Server Code Setup: Create &lt;code&gt;.env&lt;/code&gt; File
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In your server project, create a &lt;code&gt;.env&lt;/code&gt; file in the root directory and add the following environment variables (make sure to replace the values with your own generated ones):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Server Configuration this for loacl
PORT=5000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=Sharan@123
DB_DATABASE=people_pro

# Railway MySQL config
MYSQLHOST=tramway.proxy.rlwy.net
MYSQLPORT=17091
MYSQLUSER=root
MYSQLPASSWORD=RcMTiimLAURmUcweLMDtrgDwGvmZdFZw
MYSQLDATABASE=railway

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  9. Update &lt;code&gt;db.js&lt;/code&gt; (Database Connection)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Update your database connection code (&lt;code&gt;db.js&lt;/code&gt;) with the correct environment variables, and make sure it's configured to connect to the Railway MySQL service:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
// This code for local
import mysql from "mysql2"

import dotenv from 'dotenv';
dotenv.config();

const con = mysql.createConnection({
    host:process.env.DB_HOST,
    user:process.env.DB_USER,
    password:process.env.DB_PASSWORD,
    database:process.env.DB_DATABASE

})

con.connect(function(error){
    if(error){
        return console.log("Connection error");

    }else{
        return console.log("Coonected");

    }
})
export default con;


// This code for server
import mysql from "mysql2";
import dotenv from "dotenv";

dotenv.config();

const con = mysql.createConnection({
  host: process.env.MYSQLHOST,
  port: process.env.MYSQLPORT,
  user: process.env.MYSQLUSER,
  password: process.env.MYSQLPASSWORD,
  database: process.env.MYSQLDATABASE,
});

con.connect((error) =&amp;gt; {
  if (error) {
    console.log("❌ Connection error:", error);
  } else {
    console.log("✅ Connected to the MySQL database!");
  }
});

con.query('SHOW TABLES', (err, results) =&amp;gt; {
  if (err) {
    console.log('❌ Error:', err);
  } else {
    console.log('✅ Tables:', results);
  }
});

export default con;

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

&lt;/div&gt;



&lt;p&gt;This code ensures that the server can connect to the MySQL database hosted by Railway.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Push Updates to GitHub
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Commit and push the changes, including the &lt;code&gt;.env&lt;/code&gt; file and the updated &lt;code&gt;db.js&lt;/code&gt; file, to your GitHub repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Railway will automatically detect the changes and deploy the updated code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  11. Check Deployment Logs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go back to the Deployments section on Railway to check the logs for any issues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If everything is set up correctly, your MySQL service should now be connected, and your server will interact with the database seamlessly.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;You’ve successfully deployed your Node.js project with MySQL on Railway. 🚀 By configuring environment variables, updating your code, and linking your GitHub repo, your app should now seamlessly connect to the MySQL service. You can monitor deployments 🛠️, manage variables 🔧, and set up custom domains 🌐 for your project.&lt;/p&gt;

&lt;p&gt;🔑 #NodeJS | 💾 #MySQL | 🚀 #Railway | 🖥️ #Deployment | 💻 #GitHub | 🌍 #WebDevelopment | 🗄️ #DatabaseConnection&lt;/p&gt;

</description>
      <category>node</category>
      <category>mysql</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Set Up Tailwind CSS v4 Using Tailwind CLI</title>
      <dc:creator>Sharanappa</dc:creator>
      <pubDate>Thu, 06 Mar 2025 08:01:28 +0000</pubDate>
      <link>https://dev.to/sharanappa_m/how-to-set-up-tailwind-css-v4-using-tailwind-cli-1481</link>
      <guid>https://dev.to/sharanappa_m/how-to-set-up-tailwind-css-v4-using-tailwind-cli-1481</guid>
      <description>&lt;p&gt;Tailwind CSS v4 is a powerful utility-first CSS framework that helps you rapidly build custom designs. If you're looking to set up Tailwind CSS v4 using the Tailwind CLI (Command Line Interface), this guide will walk you through every step of the process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create Your Project Folder
&lt;/h2&gt;

&lt;p&gt;The first step in setting up Tailwind CSS v4 is to create a project folder. You can do this by navigating to your desired location and running the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir my-tailwind-project
cd my-tailwind-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;my-tailwind-project&lt;/code&gt; with your desired project name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Initialize the Project with npm
&lt;/h2&gt;

&lt;p&gt;Once inside your project folder, initialize it as a Node.js project by running:&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;This creates a &lt;code&gt;package.json&lt;/code&gt; file, where all your project dependencies will be stored.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Install Tailwind CSS v4 and Tailwind CLI
&lt;/h2&gt;

&lt;p&gt;With your &lt;code&gt;package.json&lt;/code&gt; file ready, install Tailwind CSS v4 and the Tailwind CLI tool by running:&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 tailwindcss@4 @tailwindcss/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This installs the necessary dependencies, specifically Tailwind CSS v4 along with the CLI tool to compile your styles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Create the Input CSS File
&lt;/h2&gt;

&lt;p&gt;Now, create a file for Tailwind to be imported into. First, make the &lt;code&gt;src&lt;/code&gt; directory and then create the &lt;code&gt;input.css&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir src
touch src/input.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;src/input.css&lt;/code&gt; and add the following line to import Tailwind CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import "tailwindcss";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file will now include the Tailwind styles when compiled.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Set Up Your HTML File
&lt;/h2&gt;

&lt;p&gt;Create an &lt;code&gt;index.html&lt;/code&gt; file inside the &lt;code&gt;src&lt;/code&gt;directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch src/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;src/index.html&lt;/code&gt; and add this basic HTML structure:&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;!doctype html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
  &amp;lt;link href="./output.css" rel="stylesheet"&amp;gt;
  &amp;lt;title&amp;gt;Tailwind Project&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;h1 class="text-3xl font-bold underline"&amp;gt;
     Hey coders, it's Sharan here, diving into Tailwind CSS v4!
  &amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;This structure links to the &lt;code&gt;output.css&lt;/code&gt; file that will be generated once we compile the Tailwind styles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Compile Tailwind CSS Using the CLI
&lt;/h2&gt;

&lt;p&gt;To compile the CSS, run the Tailwind CLI with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx @tailwindcss/cli -i ./src/input.css -o ./src/output.css --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-i ./src/input.css&lt;/code&gt;: Specify the input file (your input.css with Tailwind's imports).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;-o ./src/output.css&lt;/code&gt;: Specify the output file (where the compiled CSS will be saved).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--watch&lt;/code&gt;: Automatically recompiles the CSS when changes are made.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the process runs, it will generate the &lt;code&gt;output.css&lt;/code&gt; file in your &lt;code&gt;src&lt;/code&gt; directory containing all of Tailwind’s utility classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Open Your Project in a Live Server
&lt;/h2&gt;

&lt;p&gt;Now that your CSS is compiled, you can open your &lt;code&gt;index.html&lt;/code&gt; file in a live server. If you're using Visual Studio Code, you can install the "Live Server" extension to view your project in the browser with live reloading.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: Set Up IntelliSense for Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;To make it easier to work with Tailwind CSS, especially for autocompletion and suggestions, install the Tailwind CSS IntelliSense extension in your code editor (e.g., VS Code).&lt;/p&gt;

&lt;p&gt;Additionally, create a &lt;code&gt;tailwind.config.js&lt;/code&gt; file in your project folder to further customize your Tailwind configuration. Run the following command to generate the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch tailwind.config.js
npx tailwindcss init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration file allows you to extend or modify the default settings of Tailwind CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 9: Enjoy the Tailwind Experience
&lt;/h2&gt;

&lt;p&gt;That’s it! You have successfully set up Tailwind CSS v4 in your project using the Tailwind CLI. Now, you can start building your project using Tailwind’s utility-first approach to styling.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;With Tailwind CSS v4 and the Tailwind CLI, you’re all set to create custom designs efficiently. 🚀 Customize your project with the configuration file, and enhance your workflow with Tailwind CSS IntelliSense. 🎨 &lt;br&gt;
Happy coding! 👨‍💻👩‍💻&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Understanding React Router: A Step-by-Step Guide for Beginners</title>
      <dc:creator>Sharanappa</dc:creator>
      <pubDate>Sat, 21 Dec 2024 07:30:19 +0000</pubDate>
      <link>https://dev.to/sharanappa_m/understanding-react-router-a-step-by-step-guide-for-beginners-38hk</link>
      <guid>https://dev.to/sharanappa_m/understanding-react-router-a-step-by-step-guide-for-beginners-38hk</guid>
      <description>&lt;h6&gt;
  
  
  #React Router is one of the most popular libraries for handling navigation in React applications. It enables developers to build single-page applications (SPAs) with dynamic routing, creating a seamless and responsive user experience. In this guide, we'll explore the fundamentals of React Router and how to use it to build navigation in your React app.
&lt;/h6&gt;

&lt;h3&gt;
  
  
  What is React Router?
&lt;/h3&gt;

&lt;p&gt;React Router is a library that allows you to manage navigation and routing in React applications&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use React Router?
&lt;/h3&gt;

&lt;h5&gt;
  
  
  1. Dynamic Navigation:
&lt;/h5&gt;

&lt;p&gt;Enables smooth transitions between views without reloading the page.&lt;/p&gt;

&lt;h5&gt;
  
  
  2. Declarative Routing:
&lt;/h5&gt;

&lt;p&gt;Routes are defined using JSX, making them easy to read and manage.&lt;/p&gt;

&lt;h5&gt;
  
  
  3. Nested Routes:
&lt;/h5&gt;

&lt;p&gt;Allows for complex routing hierarchies.&lt;/p&gt;

&lt;h5&gt;
  
  
  4. Supports URL Parameters:
&lt;/h5&gt;

&lt;p&gt;Enables dynamic content rendering based on the URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started with React Router
&lt;/h3&gt;

&lt;h5&gt;
  
  
  Installation
&lt;/h5&gt;

&lt;p&gt;To use React Router, install the library via npm or yarn:&lt;br&gt;
&lt;code&gt;npm install react-router-dom&lt;/code&gt;&lt;br&gt;
or&lt;br&gt;
&lt;code&gt;yarn add react-router-dom&lt;/code&gt;&lt;/p&gt;
&lt;h5&gt;
  
  
  Basic Setup
&lt;/h5&gt;

&lt;p&gt;Here’s how to set up React Router in a simple React application:&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 { BrowserRouter as Router, Routes, Route } from 'react-router-dom';

function Home() {
  return &amp;lt;h2&amp;gt;Home Page&amp;lt;/h2&amp;gt;;
}

function About() {
  return &amp;lt;h2&amp;gt;About Page&amp;lt;/h2&amp;gt;;
}

function App() {
  return (
    &amp;lt;Router&amp;gt;
      &amp;lt;nav&amp;gt;
        &amp;lt;a href="/"&amp;gt;Home&amp;lt;/a&amp;gt;
        &amp;lt;a href="/about"&amp;gt;About&amp;lt;/a&amp;gt;
      &amp;lt;/nav&amp;gt;
      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path="/" element={&amp;lt;Home /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="/about" element={&amp;lt;About /&amp;gt;} /&amp;gt;
      &amp;lt;/Routes&amp;gt;
    &amp;lt;/Router&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;BrowserRouter : Wraps the application and provides routing functionality.&lt;/li&gt;
&lt;li&gt;Routes : A container for defining multiple routes.&lt;/li&gt;
&lt;li&gt;Route : Defines a path and its associated component&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Key Features of React Router
&lt;/h4&gt;

&lt;h5&gt;
  
  
  1. Dynamic Routes
&lt;/h5&gt;

&lt;p&gt;React Router supports dynamic routes using URL parameters.&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 { BrowserRouter as Router, Routes, Route, useParams } from 'react-router-dom';

function User() {
  const { id } = useParams(); // Access the dynamic URL parameter
  return &amp;lt;h2&amp;gt;User ID: {id}&amp;lt;/h2&amp;gt;;
}

function App() {
  return (
    &amp;lt;Router&amp;gt;
      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path="/user/:id" element={&amp;lt;User /&amp;gt;} /&amp;gt;
      &amp;lt;/Routes&amp;gt;
    &amp;lt;/Router&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;h5&gt;
  
  
  2.  Navigation Links
&lt;/h5&gt;

&lt;p&gt;Use &lt;code&gt;Link&lt;/code&gt; or &lt;code&gt;NavLink&lt;/code&gt; components instead of &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tags for better performance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Link } from 'react-router-dom';

function Navbar() {
  return (
    &amp;lt;nav&amp;gt;
      &amp;lt;Link to="/"&amp;gt;Home&amp;lt;/Link&amp;gt;
      &amp;lt;Link to="/about"&amp;gt;About&amp;lt;/Link&amp;gt;
    &amp;lt;/nav&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Link : Prevents full page reloads, making navigation faster.&lt;/li&gt;
&lt;li&gt;NavLink : Provides active styles for the currently active route.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  3. Lazy Loading
&lt;/h5&gt;

&lt;p&gt;Optimize performance by lazy loading 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, { lazy, Suspense } from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';

const Home = lazy(() =&amp;gt; import('./Home'));
const About = lazy(() =&amp;gt; import('./About'));

function App() {
  return (
    &amp;lt;Router&amp;gt;
      &amp;lt;Suspense fallback={&amp;lt;div&amp;gt;Loading...&amp;lt;/div&amp;gt;}&amp;gt;
        &amp;lt;Routes&amp;gt;
          &amp;lt;Route path="/" element={&amp;lt;Home /&amp;gt;} /&amp;gt;
          &amp;lt;Route path="/about" element={&amp;lt;About /&amp;gt;} /&amp;gt;
        &amp;lt;/Routes&amp;gt;
      &amp;lt;/Suspense&amp;gt;
    &amp;lt;/Router&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  Conclusion
&lt;/h4&gt;

&lt;p&gt;React Router simplifies navigation in React applications by providing a declarative and dynamic way to manage routes. Whether you’re building simple SPAs or complex nested applications, mastering React Router will significantly enhance your development skills.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>frontend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Unlocking ES6-Essential Features Every Developer Should Know</title>
      <dc:creator>Sharanappa</dc:creator>
      <pubDate>Sun, 08 Dec 2024 07:32:32 +0000</pubDate>
      <link>https://dev.to/sharanappa_m/unlocking-es6-essential-features-every-developer-should-know-2ge</link>
      <guid>https://dev.to/sharanappa_m/unlocking-es6-essential-features-every-developer-should-know-2ge</guid>
      <description>&lt;p&gt;The arrival of ECMAScript 2015 (ES6) revolutionized JavaScript with several groundbreaking features. Whether you're a beginner or an experienced developer, understanding these features is essential for writing modern and efficient JavaScript. Let's explore the top 10 ES6 features every developer should know&lt;/p&gt;

&lt;h2&gt;
  
  
  01. Arrow Functions:
&lt;/h2&gt;

&lt;p&gt;Arrow functions are a concise syntax for writing anonymous functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  For instance, instead of writing this:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const square = function (value) {
  return value * value;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  You can write the same code with an arrow function:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const square = (value) =&amp;gt; value * value;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  02. Spread Operator:
&lt;/h2&gt;

&lt;p&gt;The spread operator allows you to spread elements of an array or properties of an object into a new array or object. This is useful for merging arrays or objects, or for spreading an array into function arguments.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3];
const newNumbers = [...numbers, 4, 5];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  03. Default Parameters:
&lt;/h2&gt;

&lt;p&gt;Default parameters allow you to specify default values for function parameters in case no value is passed. This makes it easier to handle edge cases and reduces the need for conditional statements.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const greet = (name = "Sharan") =&amp;gt; {
  console.log(`Hello, ${name}!`);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  04. Template Literals:
&lt;/h2&gt;

&lt;p&gt;Template literals allow you to embed expressions in string literals. They use backticks instead of quotes and can be multi-line as well.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = "Sharan";
const greeting = `Hello, ${name}!`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  05. Destructuring
&lt;/h2&gt;

&lt;p&gt;Destructuring allows you to extract data from arrays or objects into separate variables. This makes it easier to work with complex data structures.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3];
const [first, second, third] = numbers; //Array destructure

const person ={
  name: "Sharan",
  age: 25,
}
const {name, age} = person; // Object destructure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  06. Rest Parameters:
&lt;/h2&gt;

&lt;p&gt;Rest parameters allow you to collect an indefinite number of arguments into an array. This is useful for writing functions that can accept any number of arguments.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const sum = (...numbers) =&amp;gt; {
  let result = 0;
  for (const number of numbers) {
    result += number;
  }
  return result;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  07. Promise:
&lt;/h2&gt;

&lt;p&gt;Promises are a way to handle asynchronous operations in JavaScript. They provide a way to handle errors, and can be combined to create complex asynchronous flows.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getData = () =&amp;gt; {
  return new Promise((resolve, reject) =&amp;gt; {
    setTimeout(() =&amp;gt; {
      resolve("Data fetched");
    }, 1000);
  });
};

getData().then((data) =&amp;gt; {
  console.log(data);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  08. Class Definitions:
&lt;/h2&gt;

&lt;p&gt;Class definitions provide a more object-oriented way of defining objects in JavaScript. They make it easier to create reusable objects with inheritance and encapsulation.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
  constructor(name) {
    this.name = name;
  }

  greet() {
    console.log(`Hello, my name is ${this.name}`);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  09. Modules:
&lt;/h2&gt;

&lt;p&gt;Modules allow you to organize your code into smaller, reusable pieces. This makes it easier to manage complex projects and reduces the risk of naming collisions.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// greeting.js
export const greet = (name) =&amp;gt; {
  console.log(`Hello, ${name}!`);
};

// main.js
import { greet } from "./greeting.js";
greet("Sharan");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. Map and Set:
&lt;/h2&gt;

&lt;p&gt;The Map and Set data structures provide an efficient way to store unique values in JavaScript. They also provide a variety of useful methods for searching and manipulating the data.&lt;/p&gt;

&lt;h4&gt;
  
  
  For Example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Creating a Map
const map = new Map();
map.set("name", "Sharan");
map.set("age", 25);

// Accessing values in a Map
console.log(map.get("name")); // Output: Sharan
console.log(map.get("age")); // Output: 25

// Iterating over a Map
for (const [key, value] of map) {
  console.log(`${key}: ${value}`);
}

// Output:
// name: Sharan
// age: 25

// Creating a Set
const set = new Set();
set.add("Sharan");
set.add("Basava");
set.add("Raju");

// Iterating over a Set
for (const name of set) {
  console.log(name);
}

// Output:
// Sharan
// Basava
// Raju
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;These ES6 features not only make JavaScript more powerful but also enhance code readability and maintainability. Mastering them is crucial for modern JavaScript development.&lt;/p&gt;

&lt;p&gt;What’s your favorite ES6 feature? Let me know in the comments 💬!&lt;/p&gt;

</description>
      <category>react</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
