<?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: Narenthera Prasanth M</title>
    <description>The latest articles on DEV Community by Narenthera Prasanth M (@narenmnp).</description>
    <link>https://dev.to/narenmnp</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%2F417630%2F7793f5e3-f2a0-4184-aba9-c11941cda371.jpeg</url>
      <title>DEV Community: Narenthera Prasanth M</title>
      <link>https://dev.to/narenmnp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/narenmnp"/>
    <language>en</language>
    <item>
      <title>Unleashing the Power of React Context: Simplifying State Sharing</title>
      <dc:creator>Narenthera Prasanth M</dc:creator>
      <pubDate>Sun, 31 Mar 2024 15:01:14 +0000</pubDate>
      <link>https://dev.to/narenmnp/unleashing-the-power-of-react-context-simplifying-state-sharing-4388</link>
      <guid>https://dev.to/narenmnp/unleashing-the-power-of-react-context-simplifying-state-sharing-4388</guid>
      <description>&lt;p&gt;&lt;em&gt;React Context API&lt;/em&gt; is a built-in feature in React that allows for easier management of state and props across different components without the need for prop drilling. It creates a global scope for data, making it accessible to any component that needs it, regardless of its position in the component tree.&lt;/p&gt;

&lt;p&gt;Here's an example of how you can use the React Context API:&lt;/p&gt;

&lt;p&gt;Let's say we have a simple e-commerce website where users can add items to their cart and view the total cost of those items. Without using the Context API, we would have to pass down the cart object through multiple levels of child components as props until it reaches the component that displays the total cost. This process is known as "prop drilling" and can become cumbersome and difficult to manage as the application grows.&lt;/p&gt;

&lt;p&gt;To solve this problem, we can create a new context using the createContext() method provided by React:&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 CartContext = React.createContext();

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

&lt;/div&gt;



&lt;p&gt;Next, we can define our CartProvider, which will be responsible for managing the state of our cart object:&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 CartContext from './CartContext';

function CartProvider(props) {
  const [cart, setCart] = useState([]);

  function addItemToCart(item) {
    setCart([...cart, item]);
  }

  return (
    &amp;lt;CartContext.Provider value={{ cart, addItemToCart }}&amp;gt;
      {props.children}
    &amp;lt;/CartContext.Provider&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;In this example, we are defining a CartProvider component that uses the useState hook to maintain the state of the cart. We also define a helper function called addItemToCart that adds a new item to the cart array. The value prop passed to the CartContext.Provider contains both the current cart object and the addItemToCart function.&lt;/p&gt;

&lt;p&gt;Now, let's see how we can consume this context in another component:&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, { useContext } from 'react';
import CartContext from './CartContext';

function TotalCost() {
  const { cart } = useContext(CartContext);

  const totalCost = cart.reduce((accumulator, currentValue) =&amp;gt; {
    return accumulator + currentValue.price * currentValue.quantity;
  }, 0);

  return &amp;lt;div&amp;gt;{totalCost}&amp;lt;/div&amp;gt;;
}

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

&lt;/div&gt;



&lt;p&gt;In this example, we are consuming the CartContext using the useContext hook. By doing so, we now have access to the cart object defined in the CartProvider component. We can then calculate the total cost based on the contents of the cart array.&lt;/p&gt;

&lt;p&gt;By using the React Context API, we were able to easily share state between two unrelated components without having to pass props down through multiple layers of intermediate components.&lt;/p&gt;

&lt;p&gt;Comparing to Redux:&lt;/p&gt;

&lt;p&gt;Redux is a popular library used for managing state in large-scale React applications. While similar in some ways to the React Context API, there are some key differences between the two. Here are some points comparing React Context API and Redux:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scope&lt;/strong&gt;: React Context has a more limited scope compared to Redux. With React Context, state is only available within the component hierarchy rooted at the provider component. In contrast, Redux provides a single source of truth for state that is globally accessible throughout the entire application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Immutability&lt;/strong&gt;: Redux enforces immutable updates to state, while React Context does not. This means that when updating state in Redux, developers must always produce a new copy of the state instead of modifying the existing state directly. In contrast, React Context allows developers to modify state directly if they choose to do so.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Middleware&lt;/strong&gt;: Redux supports middleware such as redux-thunk or redux-saga for handling side effects like async actions. While there are libraries that provide similar functionality for React Context, these features are not included out of the box.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: Both React Context and Redux use memoization under the hood to optimize performance. However, since Redux maintains a single source of truth for state, it can perform better than React Context in certain situations where many components depend on the same piece of state.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, whether to use React Context or Redux depends on the specific requirements of your project. For smaller projects or cases where state sharing is required only within a small part of the component hierarchy, React Context may be sufficient. However, for larger projects with complex state management needs, Redux may be a better fit.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>learning</category>
    </item>
    <item>
      <title>Transforming Digital Experiences: An Introduction to Progressive Web Applications (PWAs)</title>
      <dc:creator>Narenthera Prasanth M</dc:creator>
      <pubDate>Sat, 30 Mar 2024 07:00:09 +0000</pubDate>
      <link>https://dev.to/narenmnp/transforming-digital-experiences-an-introduction-to-progressive-web-applications-pwas-1c64</link>
      <guid>https://dev.to/narenmnp/transforming-digital-experiences-an-introduction-to-progressive-web-applications-pwas-1c64</guid>
      <description>&lt;p&gt;&lt;em&gt;Progressive Web Applications(PWAs)&lt;/em&gt; are web applications that combine the best features of both websites and native mobile applications. They are designed to offer fast, reliable, and engaging experiences even on unreliable network connections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbtd7fgi3owhcf087ub1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdbtd7fgi3owhcf087ub1.png" alt="PWA" width="800" height="658"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of PWAs:&lt;/strong&gt;    &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fast Load Times: PWAs can load quickly, even on slow networks, thanks to optimizations like caching and preloading.    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Offline Mode: PWAs can cache resources locally, enabling offline mode and faster load times.   &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Engaging UX: PWAs can provide immersive full-screen experiences, complete with animations and interactions similar to native mobile apps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy Installation: Users can easily install PWAs on their home screen, without needing to go through the app store.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cross-platform compatibility: PWAs can run on any platform that supports modern web technologies, including desktop browsers, Android, iOS, and Chrome OS.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Purpose of PWAs:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The primary goal of PWAs is to provide a seamless and engaging user experience that combines the benefits of web and native mobile applications. By offering fast load times, offline mode, and full-screen experiences, PWAs aim to bridge the gap between traditional web pages and native mobile apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features of PWAs:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Responsive Design: PWAs are responsive and adapt to various screen sizes and orientations.    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Service Workers: PWAs use service workers to enable background sync, push notifications, and offline capabilities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTPS Requirement: PWAs require secure communication over HTTPS protocol to protect user data.    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Manifest File: PWAs use manifest files to declare metadata about the app, such as iconography, colors, and splash screens.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linkability: PWAs can be shared via URLs, unlike native mobile apps that require download and installation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage of PWAs:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PWAs can be used in a variety of scenarios, including e-commerce, news sites, social media platforms, productivity tools, and gaming. They are particularly well suited for businesses looking to engage customers on mobile devices, without requiring them to download and install a native app.&lt;/p&gt;

&lt;p&gt;Some examples of successful PWA implementations include Twitter Lite, Starbucks, Flipkart, Alibaba, and Trivago. These companies have reported significant improvements in engagement metrics, conversion rates, and overall customer satisfaction after implementing PWAs.&lt;/p&gt;

&lt;p&gt;Overall, PWAs represent a powerful tool for businesses looking to deliver high-quality, performant, and engaging web experiences. By combining the strengths of web and native mobile applications, PWAs offer a promising path forward for the future of digital experiences.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>pwa</category>
      <category>ux</category>
    </item>
    <item>
      <title>From 'I Will' to 'I Do': Applying Agile Principles with a realtime example</title>
      <dc:creator>Narenthera Prasanth M</dc:creator>
      <pubDate>Fri, 29 Mar 2024 18:40:25 +0000</pubDate>
      <link>https://dev.to/narenmnp/from-i-will-to-i-do-applying-agile-principles-with-a-real-life-example-18b0</link>
      <guid>https://dev.to/narenmnp/from-i-will-to-i-do-applying-agile-principles-with-a-real-life-example-18b0</guid>
      <description>&lt;p&gt;&lt;em&gt;Agile&lt;/em&gt; is an iterative and incremental approach to project management and product development that emphasizes flexibility, collaboration, and continuous improvement. It is a mindset and set of principles that guide teams in delivering value to customers or stakeholders in a more responsive and adaptive manner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyvr6m90fov07ke8rv7uq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyvr6m90fov07ke8rv7uq.png" alt="Agile Team" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Here are the key aspects of the agile approach:
&lt;/h2&gt;

&lt;p&gt;Consider the example of planning a wedding using an agile approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Iterative and Incremental Delivery:&lt;/strong&gt; Instead of trying to plan the entire wedding upfront, agile teams work in short iterations or sprints, delivering small increments of value. For the wedding, the first iteration could be creating a rough guest list and securing the venue and date. Subsequent iterations could focus on specific tasks like finalizing the menu, booking vendors, or selecting decorations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adaptive Planning:&lt;/strong&gt; Agile teams recognize that requirements can change, and they embrace this change by regularly re-evaluating and adjusting their plans and priorities based on feedback and changing needs. In the wedding example, you might discover that the initial guest list is too large for the chosen venue, or that the date conflicts with another important event for some guests. With the agile approach, you can adapt your plans accordingly in the next iteration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-Functional Collaboration:&lt;/strong&gt; Agile teams are cross-functional, with members from different disciplines working together throughout the project lifecycle. For a wedding, this could involve collaboration between the couple, their families, wedding planners, caterers, florists, and other vendors, ensuring everyone is aligned and contributing their expertise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customer Collaboration:&lt;/strong&gt; Agile emphasizes close collaboration with customers or end-users, seeking their feedback and involving them in the development process to ensure that the product or solution meets their needs. In the case of a wedding, the "customers" are the couple getting married, and their input and feedback should be regularly sought and incorporated into the planning process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Continuous Improvement:&lt;/strong&gt; Agile teams reflect on their processes and practices at the end of each iteration, identifying areas for improvement and adjusting their approach accordingly. For the wedding planning, this could involve reviewing the progress after each iteration, gathering feedback from the couple and other stakeholders, and making necessary adjustments for the next iteration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Empowered and Self-Organizing Teams:&lt;/strong&gt; Agile teams are typically self-organizing and empowered to make decisions, manage their own workload, and take ownership of their work. In the wedding context, the wedding planning team (whether it's the couple themselves or hired professionals) should be empowered to make decisions and manage the planning process effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Focus on Working Solutions:&lt;/strong&gt; Agile prioritizes the delivery of working software or solutions over comprehensive documentation, recognizing that delivering value early and often is more important than following a rigid plan. For the wedding, this could mean prioritizing the actual execution of tasks (e.g., booking vendors, selecting decor) over extensive documentation or planning, while still maintaining a general framework.&lt;/p&gt;

&lt;p&gt;Agile methodologies, such as Scrum, Kanban, and Lean, provide frameworks and practices for implementing these principles in various domains, including software development, product management, project management, and even non-technical areas like event planning or marketing campaigns.&lt;/p&gt;

&lt;p&gt;The key idea behind agile is to embrace change, foster collaboration, and deliver value incrementally while continuously adapting and improving based on feedback and changing circumstances. By applying these principles to wedding planning, couples can ensure a more flexible, collaborative, and adaptive process, resulting in a successful and memorable celebration tailored to their evolving needs and preferences.&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>agile</category>
      <category>softwareengineering</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript Promises</title>
      <dc:creator>Narenthera Prasanth M</dc:creator>
      <pubDate>Mon, 12 Feb 2024 03:37:24 +0000</pubDate>
      <link>https://dev.to/narenmnp/javascript-promises-3lgm</link>
      <guid>https://dev.to/narenmnp/javascript-promises-3lgm</guid>
      <description>&lt;p&gt;A &lt;em&gt;JavaScript Promise&lt;/em&gt; is an object representing the eventual completion or failure of an asynchronous operation. It allows you to handle asynchronous operations more elegantly and provides a way to perform tasks asynchronously and handle their results later.&lt;/p&gt;

&lt;p&gt;Here's a real-life example story to illustrate JavaScript Promise:&lt;/p&gt;

&lt;p&gt;Imagine you're a student waiting for your exam results. You have no control over when the results will be available, but you want to be prepared to celebrate or console yourself based on the outcome. So, you decide to use a Promise to represent this situation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnuj2w3776pj2i1b4xw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqnuj2w3776pj2i1b4xw6.png" alt="Image description" width="800" height="609"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In this example, &lt;em&gt;waitForExamResults&lt;/em&gt; is a Promise representing the process of waiting for exam results. Inside the Promise constructor function, there's a simulation of obtaining the exam score asynchronously after a delay of 3 seconds.&lt;/li&gt;
&lt;li&gt;    If the exam score is 60 or higher, the Promise resolves with a success message indicating the passing score. Otherwise, it rejects with an error message indicating failure.&lt;/li&gt;
&lt;li&gt;    The then() method is used to handle the fulfillment of the Promise (passing scenario), and the catch() method is used to handle the rejection of the Promise (failing scenario).&lt;/li&gt;
&lt;li&gt;    When you run this code, it first logs "Waiting for exam results...". After 3 seconds, it logs either "Success: Congratulations! You passed the exam with a score of X." or "Error: Sorry, you failed the exam with a score of X.", depending on the randomly generated exam score.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>web</category>
    </item>
    <item>
      <title>Create custom alias for 127.0.0.1 in Ubuntu</title>
      <dc:creator>Narenthera Prasanth M</dc:creator>
      <pubDate>Tue, 21 Sep 2021 11:23:55 +0000</pubDate>
      <link>https://dev.to/narenmnp/create-custom-alias-for-127-0-0-1-in-ubuntu-37h</link>
      <guid>https://dev.to/narenmnp/create-custom-alias-for-127-0-0-1-in-ubuntu-37h</guid>
      <description>&lt;p&gt;In some cases developers need some alternates for &lt;em&gt;localhost&lt;/em&gt; to access the IP &lt;em&gt;127.0.0.1&lt;/em&gt; in our system.&lt;/p&gt;

&lt;p&gt;Here we are going to see how to setup alias for IP &lt;em&gt;127.0.0.1&lt;/em&gt; in Ubuntu. &lt;/p&gt;

&lt;h5&gt;
  
  
  Step 1 :
&lt;/h5&gt;

&lt;p&gt;We need to edit &lt;em&gt;/etc/hosts&lt;/em&gt; file to add new aliases&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fwoydd76p19a48xgrvlo4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fwoydd76p19a48xgrvlo4.png" alt="Step 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In hosts file, you can see the &lt;em&gt;localhost&lt;/em&gt; configured as alias for &lt;em&gt;127.0.0.1&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F279p76y36s1v7b79gy81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F279p76y36s1v7b79gy81.png" alt="Step 1.1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  Step 2 :
&lt;/h5&gt;

&lt;p&gt;Add your alias like below and save it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fum9zwp5c2ln5zg6f41jp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fum9zwp5c2ln5zg6f41jp.png" alt="Step 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now localhost, &lt;em&gt;abc.fake.com&lt;/em&gt; and &lt;em&gt;xyz.test.com&lt;/em&gt; are aliases for IP &lt;em&gt;127.0.0.1&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt; Browser always search in your local domain registry before reached to DNS server.&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>localhost</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
