<?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: Devi</title>
    <description>The latest articles on Forem by Devi (@uthirabalan).</description>
    <link>https://forem.com/uthirabalan</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%2F1152383%2F4dfed8d1-744d-4c1e-8036-b23dfea9b5a0.png</url>
      <title>Forem: Devi</title>
      <link>https://forem.com/uthirabalan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/uthirabalan"/>
    <language>en</language>
    <item>
      <title>Dynamic routing in React</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Tue, 27 Aug 2024 09:11:03 +0000</pubDate>
      <link>https://forem.com/uthirabalan/dynamic-routing-in-react-393o</link>
      <guid>https://forem.com/uthirabalan/dynamic-routing-in-react-393o</guid>
      <description>&lt;p&gt;Dynamic routing in React allows you to create routes based on dynamic data or parameters, enabling more flexible and powerful navigation within your application. This is particularly useful for applications that need to render different components based on user input or other dynamic factors.&lt;/p&gt;

&lt;p&gt;Setting Up Dynamic Routing with React Router&lt;br&gt;
You’ll typically use the react-router-dom library to implement dynamic routing in React. Here’s a step-by-step guide:&lt;/p&gt;

&lt;p&gt;Install React Router: First, you need to install react-router-dom if you haven’t already:&lt;br&gt;
npm install react-router-dom&lt;/p&gt;

&lt;p&gt;Create Routes: Define your routes using the  component. Use dynamic segments in the path to capture parameters.&lt;br&gt;
JavaScript&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, Route, Switch } from 'react-router-dom';
import Home from './Home';
import UserProfile from './UserProfile';

const App = () =&amp;gt; {
    return (
        &amp;lt;Router&amp;gt;
            &amp;lt;Switch&amp;gt;
                &amp;lt;Route exact path="/" component={Home} /&amp;gt;
                &amp;lt;Route path="/user/:id" component={UserProfile} /&amp;gt;
            &amp;lt;/Switch&amp;gt;
        &amp;lt;/Router&amp;gt;
    );
};

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

&lt;/div&gt;



&lt;p&gt;Access Route Parameters: Use the useParams hook to access dynamic parameters within your components.&lt;br&gt;
JavaScript&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 { useParams } from 'react-router-dom';

const UserProfile = () =&amp;gt; {
    const { id } = useParams();

    return (
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;User Profile&amp;lt;/h1&amp;gt;
            &amp;lt;p&amp;gt;User ID: {id}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

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

&lt;/div&gt;



&lt;p&gt;Example: Dynamic User Profiles&lt;br&gt;
Let’s create a simple example where we navigate to different user profiles based on the user ID in the URL.&lt;/p&gt;

&lt;p&gt;Home Component: This component will have links to different user profiles.&lt;br&gt;
JavaScript&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 { Link } from 'react-router-dom';

const Home = () =&amp;gt; {
    return (
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;Home&amp;lt;/h1&amp;gt;
            &amp;lt;ul&amp;gt;
                &amp;lt;li&amp;gt;&amp;lt;Link to="/user/1"&amp;gt;User 1&amp;lt;/Link&amp;gt;&amp;lt;/li&amp;gt;
                &amp;lt;li&amp;gt;&amp;lt;Link to="/user/2"&amp;gt;User 2&amp;lt;/Link&amp;gt;&amp;lt;/li&amp;gt;
                &amp;lt;li&amp;gt;&amp;lt;Link to="/user/3"&amp;gt;User 3&amp;lt;/Link&amp;gt;&amp;lt;/li&amp;gt;
            &amp;lt;/ul&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

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

&lt;/div&gt;



&lt;p&gt;UserProfile Component: This component will display the user ID from the URL.&lt;br&gt;
JavaScript&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 { useParams } from 'react-router-dom';

const UserProfile = () =&amp;gt; {
    const { id } = useParams();

    return (
        &amp;lt;div&amp;gt;
            &amp;lt;h1&amp;gt;User Profile&amp;lt;/h1&amp;gt;
            &amp;lt;p&amp;gt;User ID: {id}&amp;lt;/p&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

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

&lt;/div&gt;



&lt;p&gt;App Component: This component sets up the router and defines the routes.&lt;br&gt;
JavaScript&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, Route, Switch } from 'react-router-dom';
import Home from './Home';
import UserProfile from './UserProfile';

const App = () =&amp;gt; {
    return (
        &amp;lt;Router&amp;gt;
            &amp;lt;Switch&amp;gt;
                &amp;lt;Route exact path="/" component={Home} /&amp;gt;
                &amp;lt;Route path="/user/:id" component={UserProfile} /&amp;gt;
            &amp;lt;/Switch&amp;gt;
        &amp;lt;/Router&amp;gt;
    );
};

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

&lt;/div&gt;



</description>
      <category>react</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Asynchronous JS</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Sun, 25 Aug 2024 09:15:13 +0000</pubDate>
      <link>https://forem.com/uthirabalan/asynchronous-js-jom</link>
      <guid>https://forem.com/uthirabalan/asynchronous-js-jom</guid>
      <description>&lt;p&gt;JavaScript is synchornous single threaded language.&lt;br&gt;
But, We can acheive Asynchornous operation using following 3 methods&lt;/p&gt;

&lt;p&gt;1.Callback&lt;br&gt;
2.Promises&lt;br&gt;
3.Async await&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Callbacks&lt;/strong&gt;&lt;br&gt;
A callback is a function passed as an argument to another function, which is then executed inside the outer function to complete some kind of routine or action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fetchData(callback) {
    setTimeout(() =&amp;gt; {
        callback('Data fetched');
    }, 1000);
}

function displayData(data) {
    console.log(data);
}

fetchData(displayData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, fetchData simulates an asynchronous operation using setTimeout. Once the data is “fetched,” it calls the displayData function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Promises&lt;/strong&gt;&lt;br&gt;
Promises provide a more robust way to handle asynchronous operations. A Promise represents a value that may be available now, or in the future, or never.&lt;br&gt;
&lt;/p&gt;

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

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

&lt;/div&gt;



&lt;p&gt;Here, fetchData returns a Promise that resolves after 1 second.The then method is used to handle the resolved value, and catch handles any errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Async/Await&lt;/strong&gt;&lt;br&gt;
Async/Await is syntactic sugar built on top of Promises, making asynchronous code look and behave more like synchronous code.async&lt;br&gt;
&lt;/p&gt;

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

async function displayData() {
    try {
        const data = await fetchData();
        console.log(data);
    } catch (error) {
        console.error(error);
    }
}

displayData();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, fetchData returns a Promise, and displayData uses the await keyword to wait for the Promise to resolve. The try/catch block is used to handle any errors.&lt;/p&gt;

</description>
      <category>callback</category>
      <category>aysncawait</category>
      <category>promises</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Simple React Interview Questions and Answers 🔍</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Thu, 04 Apr 2024 14:30:06 +0000</pubDate>
      <link>https://forem.com/uthirabalan/simple-react-interview-questions-and-answers-4njp</link>
      <guid>https://forem.com/uthirabalan/simple-react-interview-questions-and-answers-4njp</guid>
      <description>&lt;p&gt;&lt;strong&gt;1.What is state &amp;amp; props / Difference between state and props:&lt;/strong&gt;&lt;br&gt;
In reacting while building an application we'll break the page into small reusable components to make it more readable and to manage easily,&lt;br&gt;
State: we've to use state to manage data inside a component.&lt;br&gt;
Props: Props are some data that a component receives from another component&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. What "create-react-app" will do?&lt;/strong&gt;&lt;br&gt;
create-react-app will create a react project with necessary packages and bundlers (react by default has a bundler called web pack). It'll compile and run the project in localhost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. what is the robot.txt file in react?&lt;/strong&gt;&lt;br&gt;
if web designers create something on their website and don't want Google or other search engines to access it, they'll write it in robot.txt and it will be helpful for SEO too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Types of components in react?&lt;/strong&gt;&lt;br&gt;
Functional components: A normal JS function that can manage multiple functions inside that.&lt;br&gt;
Class-based components: created using class keywords in Javascript.&lt;br&gt;
Functional is a new way, easy to use compared to class components&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. What is JSX?&lt;/strong&gt;&lt;br&gt;
JavaScript XML, which will be used to create HTML elements inside DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. what are Hooks in react?&lt;/strong&gt;&lt;br&gt;
Hooks are utility functions. to manage a state in functional components we'll use state (useState hook) from react.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useState:&lt;/strong&gt; to create a special dynamic variable by re-rendering automatically.&lt;br&gt;
UseState will return an array &lt;br&gt;
const [data,setData] = useState('')&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>JavaScript variables and scope</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Tue, 02 Apr 2024 10:05:52 +0000</pubDate>
      <link>https://forem.com/uthirabalan/javascript-variables-and-scope-289m</link>
      <guid>https://forem.com/uthirabalan/javascript-variables-and-scope-289m</guid>
      <description>&lt;h1&gt;
  
  
  JavaScript Identifiers
&lt;/h1&gt;

&lt;p&gt;In JavaScript, we can assign names to functions, variables, and objects. These names are used to reference and utilize the specific function, variable, or object.&lt;/p&gt;

&lt;p&gt;Just as we all have names to identify us, functions, variables, and objects in JavaScript have unique names. These are called identifiers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rules for Identifiers:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Within a scope, the variable name must be unique. This applies to both block scope and global scope. If the same name is given to multiple variables, the most recently assigned value will be used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Identifiers should start with an uppercase letter, lowercase letter, underscore, or dollar sign. This rule applies only to the first letter of an identifier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reserved keywords must not be used as identifiers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Identifiers are case-sensitive: ‘helloWorld’ and ‘HelloWorld’ are different.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When using strict mode, certain keywords are also restricted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid using future reserved words.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Other reserved words should be avoided as well.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Variables and Scope
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Any type of variable can be used; once it’s assigned, we can change the type of variable anywhere in the code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To declare a variable, name it (using &lt;code&gt;var&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt;, or &lt;code&gt;const&lt;/code&gt;), and initialize it using the assignment operator:&lt;/p&gt;

&lt;p&gt;var name = “Devi”;&lt;/p&gt;

&lt;p&gt;=&amp;gt;The variable name should start with an uppercase letter, lowercase letter, underscore, or dollar sign. This rule applies only to the first letter of an identifier.&lt;/p&gt;

&lt;p&gt;=&amp;gt; There should be no space within a single variable name (to avoid an ‘unexpected identifier’ syntax error).&lt;/p&gt;

&lt;p&gt;=&amp;gt;While non-Latin words can be used, it’s best to avoid them.&lt;/p&gt;

&lt;p&gt;=&amp;gt;Multiple variables can be declared using a single statement&lt;/p&gt;

&lt;p&gt;var car = "Audi", name = "Devi";&lt;br&gt;
We can reassign any type of value to a variable declared with let:&lt;br&gt;
JavaScript&lt;/p&gt;

&lt;p&gt;let a = 100;&lt;br&gt;
a = "hello";&lt;br&gt;
a = { name: "Devi", dept: "ECE" };&lt;br&gt;
It’s possible to reference a variable before it’s declared:&lt;br&gt;
JavaScript&lt;/p&gt;

&lt;p&gt;name = "Devi";&lt;br&gt;
console.log(name); // Outputs: Devi&lt;br&gt;
var name;&lt;br&gt;
However, in strict mode, this will not work due to hoisting.&lt;/p&gt;

&lt;p&gt;Hoisting&lt;br&gt;
JavaScript moves variable declarations to the top of the code, which prevents errors from occurring when a variable is used before it’s declared:&lt;/p&gt;

&lt;p&gt;JavaScript&lt;/p&gt;

&lt;p&gt;name = "Devi";&lt;br&gt;
console.log(name);&lt;br&gt;
var name;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>useRef in react for beginners</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Wed, 13 Mar 2024 15:12:08 +0000</pubDate>
      <link>https://forem.com/uthirabalan/useref-in-react-for-beginners-gmp</link>
      <guid>https://forem.com/uthirabalan/useref-in-react-for-beginners-gmp</guid>
      <description>&lt;p&gt;UseRef will create a reference of a react element, by using that we can mutate the DOM element or a value that is used across the component. Also, we can store some data and that won’t cause a re-render on update.&lt;/p&gt;

&lt;p&gt;Steps to use UseRef Hook:&lt;/p&gt;

&lt;p&gt;step 1: import it from react&lt;/p&gt;

&lt;p&gt;step2: declare it as a ref variable&lt;/p&gt;

&lt;p&gt;step 3:pass the ref as an attribute to the JSX .&lt;/p&gt;

</description>
      <category>react</category>
      <category>dom</category>
      <category>reacthooks</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JS core concepts</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Tue, 12 Mar 2024 13:54:02 +0000</pubDate>
      <link>https://forem.com/uthirabalan/js-core-concepts-2n3d</link>
      <guid>https://forem.com/uthirabalan/js-core-concepts-2n3d</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Closures example:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The closure is a javascript nested function where we can access outerfunction variables inside the inner function by calling the innerfunction inside the outer function.&lt;/p&gt;

&lt;p&gt;let outerfunction = ()=&amp;gt;{&lt;br&gt;
var count = 0&lt;br&gt;
let innerFunction=()=&amp;gt;{&lt;br&gt;
  count++;&lt;br&gt;
  console.log(count)&lt;br&gt;
}&lt;br&gt;
return innerFunction;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;let increment = outerfunction()&lt;br&gt;
increment();&lt;br&gt;
increment();&lt;br&gt;
increment();&lt;br&gt;
increment();&lt;/p&gt;

</description>
    </item>
    <item>
      <title>NPM vs NPX</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Tue, 12 Mar 2024 07:55:55 +0000</pubDate>
      <link>https://forem.com/uthirabalan/npm-vs-npx-4c66</link>
      <guid>https://forem.com/uthirabalan/npm-vs-npx-4c66</guid>
      <description>&lt;p&gt;NPM:&lt;/p&gt;

&lt;p&gt;=&amp;gt; Node Package Manager&lt;/p&gt;

&lt;p&gt;=&amp;gt; As mentioned in name NPM is for install, delete, update JavaScript packages on your machine.&lt;/p&gt;

&lt;p&gt;=&amp;gt; To install a package locally on a certain project we can use the comment&lt;/p&gt;

&lt;p&gt;npm install package-name&lt;/p&gt;

&lt;p&gt;NPX:&lt;/p&gt;

&lt;p&gt;=&amp;gt;Node Package Executer&lt;/p&gt;

&lt;p&gt;=&amp;gt; NPX is a tool that use to execute packages directly, without installing them.&lt;/p&gt;

&lt;p&gt;=&amp;gt;npx comes bundled with npm version 5.2+ (or as a standalone package).&lt;/p&gt;

&lt;p&gt;=&amp;gt;To execute the locally installed package package-name all you need to do is type:&lt;/p&gt;

&lt;p&gt;npx package-name&lt;/p&gt;

</description>
    </item>
    <item>
      <title>React simple and unique interview questions which some experienced developers also don't aware</title>
      <dc:creator>Devi</dc:creator>
      <pubDate>Tue, 12 Mar 2024 07:53:15 +0000</pubDate>
      <link>https://forem.com/uthirabalan/react-simple-and-unique-interview-questions-which-some-experienced-developers-also-dont-aware-amc</link>
      <guid>https://forem.com/uthirabalan/react-simple-and-unique-interview-questions-which-some-experienced-developers-also-dont-aware-amc</guid>
      <description>&lt;p&gt;What's the purpose of keeping crossorigin in react cdn comments?&lt;/p&gt;

&lt;p&gt;crossorigin attribute helps developers optimize the rates of CDN performance, at the same time, protecting the website code from malicious scripts.&lt;/p&gt;

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