<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sameer Shukla  on Medium]]></title>
        <description><![CDATA[Stories by Sameer Shukla  on Medium]]></description>
        <link>https://medium.com/@ss.web?source=rss-492d52cc0568------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sameer Shukla  on Medium</title>
            <link>https://medium.com/@ss.web?source=rss-492d52cc0568------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:40:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ss.web/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular Signals: A New Reactive Foundation for Modern Angular Apps]]></title>
            <link>https://medium.com/@ss.web/angular-signals-a-new-reactive-foundation-for-modern-angular-apps-964ddd2a7567?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/964ddd2a7567</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[signal]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 09:11:17 GMT</pubDate>
            <atom:updated>2026-01-05T09:11:17.513Z</atom:updated>
            <content:encoded><![CDATA[<p>Angular has always been a powerful framework, but it has also been criticized for being <strong>complex, verbose, and difficult to reason about when state grows</strong>. Over the years, Angular relied heavily on <strong>Zone.js</strong>, <strong>change detection cycles</strong>, and <strong>RxJS</strong> to manage reactivity.</p><p>With <strong>Angular 16</strong>, the framework introduced <strong>Signals</strong> — a fundamental shift in how Angular thinks about state and reactivity.</p><p>Signals are not just a new API.<br> They represent a <strong>new mental model</strong> for Angular developers.</p><p>This article provides a <strong>deep introduction</strong> to Signals:</p><ul><li>Why Angular needed them</li><li>What problems they solve</li><li>How they work internally (conceptually)</li><li>How they differ from RxJS and traditional change detection</li><li>When (and when not) to use them</li></ul><h3>The Problem with Traditional Angular Reactivity</h3><p>Before Signals, Angular relied on <strong>change detection</strong> triggered by:</p><ul><li>User events</li><li>HTTP responses</li><li>Timers</li><li>Zone.js patching async APIs</li></ul><h3>Traditional Flow</h3><ol><li>Something changes (click, HTTP response, timer)</li><li>Zone.js notJS triggers change detection</li><li>Angular checks the entire component tree</li><li>Bindings are re-evaluated</li><li>UI updates</li></ol><p>This approach worked, but it had drawbacks:</p><h3>Key Issues</h3><p>❌ <strong>Over-checking</strong><br> Angular often checks more components than necessary.</p><p>❌ <strong>Hidden dependencies</strong><br> It’s not always clear <em>what</em> caused a view to update.</p><p>❌ <strong>Boilerplate</strong><br> Using RxJS for simple UI state leads to:</p><ul><li>Subjects</li><li>Subscriptions</li><li>Unsubscriptions</li><li>Async pipes everywhere</li></ul><p>❌ <strong>Mental overhead</strong><br> Developers must constantly think about:</p><ul><li>When change detection runs</li><li>OnPush strategies</li><li>Manual optimizations</li></ul><p>Angular needed a <strong>simpler, more explicit reactive primitive</strong>.</p><h3>What Exactly Is a Signal?</h3><p>A <strong>Signal</strong> is a <strong>reactive value container</strong> that:</p><ul><li>Holds a value</li><li>Tracks who reads it</li><li>Notifies dependents when the value changes</li></ul><p>Think of a signal as: <em>“A value that knows who depends on it.”</em></p><blockquote><strong>Creating a Signal</strong></blockquote><pre>import { signal } from &#39;@angular/core&#39;;<br><br>const counter = signal(0);</pre><h3>Reading Signal</h3><pre>counter(); // 0</pre><h3>Writing a Signal</h3><pre>counter.set(5);<br>counter.update(v =&gt; v + 1);</pre><h3>Why Are Signals Functions?</h3><p>This is a common question.</p><p>Angular uses function calls because:</p><ul><li>It allows Angular to <strong>track dependencies automatically</strong></li><li>It avoids proxies and magic getters</li><li>It makes reads explicit</li></ul><p>When Angular sees:</p><pre>counter();</pre><p>It knows: <em>“This code depends on </em><em>counter.”</em></p><p>That dependency is registered automatically.</p><h3>Fine-Grained Reactivity: The Core Idea</h3><p>Signals enable <strong>fine-grained reactivity</strong>, meaning:</p><ul><li>Only code that <em>actually depends</em> on a signal will re-run</li><li>No full component tree re-checks</li><li>No guessing which component changed</li></ul><h3>Example</h3><pre>const firstName = signal(&#39;Sameer&#39;);<br>const lastName = signal(&#39;Shukla&#39;);</pre><pre>const fullName = computed(() =&gt; `${firstName()} ${lastName()}`)</pre><p>If firstName changes:</p><ul><li>fullName updates</li><li>Anything using fullName() updates</li><li><strong>Nothing else runs</strong></li></ul><p>This is fundamentally different from classic Angular CD.</p><h3>Computed Signals: Derived State Done Right</h3><p>Computed signals allow you to derive state <strong>without storing redundant data</strong>.</p><pre>import { computed } from &#39;@angular/core&#39;;</pre><pre>const price = signal(100);<br>const quantity = signal(3);</pre><pre>const total = computed(() =&gt; price() * quantity());</pre><h3>Why This Is Powerful</h3><ul><li>Automatically recalculates</li><li>Memoized (cached)</li><li>Recomputes only when dependencies change</li><li>No manual subscriptions</li></ul><p>This replaces many use cases of:</p><ul><li>map()</li><li>combineLatest()</li><li>Getter functions in components</li></ul><h3>Effects: Reacting to Changes</h3><p>Signals are about <strong>state</strong>, but sometimes you need <strong>side effects</strong>:</p><ul><li>Logging</li><li>Local storage</li><li>API calls</li><li>DOM interactions</li></ul><p>That’s where effect() comes in.</p><pre>import { effect } from &#39;@angular/core&#39;;<br><br>effect(() =&gt; {<br>  console.log(&#39;Total changed:&#39;, total());<br>});</pre><p>Whenever total changes:</p><ul><li>The effect re-runs automatically</li></ul><h3>Important Rule</h3><blockquote><em>❗ Effects should not modify signals they depend on<br> Doing so can cause infinite loops.</em></blockquote><h3>Signals in Angular Components</h3><p>Signals integrate <strong>directly with templates</strong>.</p><pre>@Component({<br>  selector: &#39;app-counter&#39;,<br>  template: `<br>    &lt;button (click)=&quot;increment()&quot;&gt;+&lt;/button&gt;<br>    &lt;p&gt;Count: {{ count() }}&lt;/p&gt;<br>  `<br>})<br>export class CounterComponent {<br>  count = signal(0);</pre><pre>  increment() {<br>    this.count.update(v =&gt; v + 1);<br>  }<br>}</pre><h3>What’s Missing?</h3><ul><li>No ChangeDetectorRef</li><li>No async pipe</li><li>No subscriptions</li><li>No OnPush complexity</li></ul><p>Angular automatically knows <strong>what to update and when</strong>.</p><h3>Signals vs RxJS: A Clear Boundary</h3><p>Signals often get compared to Observables, but they solve <strong>different problems</strong>.</p><h3>Signals Are Best For</h3><p>✔ UI state<br> ✔ Local component state<br> ✔ Derived values<br> ✔ Shared synchronous state</p><h3>RxJS Is Best For</h3><p>✔ HTTP calls<br> ✔ WebSocket streams<br> ✔ Events over time<br> ✔ Complex async flows</p><p>Angular’s recommendation: <strong><em>Use RxJS for async, Signals for state.</em></strong></p><h3>Signals Without Zone.js</h3><p>One of the long-term goals of Signals is to make Angular <strong>less dependent on Zone.js</strong>.</p><p>Because Angular knows:</p><ul><li>Which signals changed</li><li>Who depends on them</li></ul><p>It can update views <strong>without global change detection cycles</strong>.</p><p>This enables:</p><ul><li>Better performance</li><li>Better SSR</li><li>Easier mental model</li></ul><h3>Conclusion</h3><p>Signals represent the <strong>most important change in Angular’s reactivity since its inception</strong>.</p><p>They:</p><ul><li>Simplify state management</li><li>Reduce boilerplate</li><li>Improve performance</li><li>Make Angular more predictable and modern</li></ul><p>Signals are not just a feature — <br> they are <strong>Angular’s future reactive foundation</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=964ddd2a7567" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Component Factory in Angular?]]></title>
            <link>https://medium.com/@ss.web/what-is-a-component-factory-in-angular-e2c79e0773fb?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2c79e0773fb</guid>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 16:44:04 GMT</pubDate>
            <atom:updated>2025-02-10T16:44:04.616Z</atom:updated>
            <content:encoded><![CDATA[<p>A <strong>Component Factory</strong> in Angular is a mechanism that allows you to dynamically create instances of a component at runtime. It is primarily used for <strong>dynamic component loading</strong> when you need to insert components into a view without defining them statically in the template.</p><p><strong>Understanding Component Factory</strong></p><p>A <strong>Component Factory</strong> (ComponentFactory&lt;T&gt;) is an Angular class that provides a way to:</p><ul><li>Create an instance of a component.</li><li>Attach it to a view container (ViewContainerRef).</li><li>Manage its lifecycle dynamically.</li></ul><p>It was commonly used with ComponentFactoryResolver before Angular 9. However, with Angular Ivy (Angular 9+), ComponentFactoryResolver is no longer necessary.</p><p><strong>ComponentFactory Example (Pre-Angular 9)</strong></p><pre>import { Component, ViewChild, ViewContainerRef, ComponentFactoryResolver } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-dynamic&#39;,<br>  template: &#39;&lt;ng-template #container&gt;&lt;/ng-template&gt;&#39;,<br>})<br>export class DynamicComponent {<br>  @ViewChild(&#39;container&#39;, { read: ViewContainerRef, static: true }) container!: ViewContainerRef;<br><br>  constructor(private resolver: ComponentFactoryResolver) {}<br><br>  loadComponent(component: any) {<br>    const factory = this.resolver.resolveComponentFactory(component);<br>    this.container.clear();<br>    this.container.createComponent(factory);<br>  }<br>}</pre><p><strong>Modern Approach (Angular 9+)</strong></p><pre>import { Component, ViewChild, ViewContainerRef } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-dynamic&#39;,<br>  template: &#39;&lt;ng-template #container&gt;&lt;/ng-template&gt;&#39;,<br>})<br>export class DynamicComponent {<br>  @ViewChild(&#39;container&#39;, { read: ViewContainerRef, static: true }) container!: ViewContainerRef;<br><br>  loadComponent(component: any) {<br>    this.container.clear();<br>    this.container.createComponent(component);<br>  }<br>}</pre><p><strong>When to Use it?</strong></p><p>It is should be used at the following time.</p><ol><li><strong>Loading Components Dynamically</strong></li><li><strong>Lazy Loading Components</strong></li><li><strong>Embedding Components in Runtime Containers</strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2c79e0773fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Content Projection: A Step-by-Step Tutorial]]></title>
            <link>https://medium.com/@ss.web/angular-content-projection-a-step-by-step-tutorial-72560febacc0?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/72560febacc0</guid>
            <category><![CDATA[single-slot-projection]]></category>
            <category><![CDATA[ng-content]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[multiple-slot-projection]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 14:36:51 GMT</pubDate>
            <atom:updated>2025-01-07T14:36:51.692Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Angular Content Projection: A Step-by-Step Tutorial</strong></p><p>Content projection is a powerful feature in Angular that allows you to insert dynamic content into components, making them more reusable and flexible. Whether you’re building a library of UI components or enhancing an existing application, understanding content projection is key to creating modular and maintainable Angular applications.</p><p>In this blog, we’ll explore what content projection is, how to implement it, and advanced techniques to make the most of it.</p><p><strong>What is Content Projection?</strong></p><p>Content projection is a mechanism by which you can pass HTML content from a parent component into a child component and display it within predefined placeholders. Angular achieves this using &lt;ng-content&gt; tags within the child component&#39;s template.</p><p><strong>Basic Content Projection</strong></p><p>Here’s how to implement basic content projection in Angular:</p><pre>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-card&#39;,<br>  template: `<br>    &lt;div class=&quot;card&quot;&gt;<br>      &lt;div class=&quot;card-header&quot;&gt;<br>        ....some content<br>      &lt;/div&gt;<br>      &lt;div class=&quot;card-body&quot;&gt;<br>        &lt;ng-content&gt;&lt;/ng-content&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  `,<br>  styleUrls: [&#39;./card.component.css&#39;]<br>})<br>export class CardComponent {}</pre><ul><li>The &lt;ng-content&gt; tag acts as a placeholder for projected content.</li></ul><pre>&lt;app-card&gt;<br>   &lt;p&gt;This is the body of the card.&lt;/p&gt;<br>&lt;/app-card&gt;</pre><p>The content inside &lt;app-card&gt; will replace the &lt;ng-content&gt; placeholders in the child component.</p><p><strong>Advanced Content Projection</strong></p><p>Multiple Slots with select</p><p>You can define multiple &lt;ng-content&gt; tags with the select attribute to project content into different sections of your component.</p><pre>@Component({<br>  selector: &#39;app-card&#39;,<br>  template: `<br>    &lt;header&gt;<br>      &lt;ng-content select=&quot;header&quot;&gt;&lt;/ng-content&gt;<br>    &lt;/header&gt;<br>    &lt;main&gt;<br>      &lt;ng-content select=&quot;main&quot;&gt;&lt;/ng-content&gt;<br>    &lt;/main&gt;<br>    &lt;footer&gt;<br>      &lt;ng-content select=&quot;footer&quot;&gt;&lt;/ng-content&gt;<br>    &lt;/footer&gt;<br>  `<br>})<br>export class CardComponent {}</pre><p>Usage</p><pre>&lt;app-card&gt;<br> &lt;header&gt;&lt;h1&gt;Angular&lt;/h1&gt;&lt;/header&gt;<br> &lt;content&gt;One framework. Mobile &amp; desktop.&lt;/content&gt;<br> &lt;footer&gt;&lt;b&gt;Super-powered by Google &lt;/b&gt;&lt;/footer&gt;<br>&lt;/app-card&gt;</pre><p><strong>Why Use Content Projection?</strong></p><ul><li><strong>Reusability</strong>: Build components that can adapt to different use cases by changing their content dynamically.</li><li><strong>Separation of Concerns</strong>: Keep logic and UI decoupled by allowing components to focus on functionality while the projected content defines the display.</li><li><strong>Flexibility</strong>: Design components with slots for customization, enhancing their adaptability.</li></ul><p><strong>Conclusion</strong></p><p>Content projection is a cornerstone of creating reusable and dynamic components in Angular. By leveraging &lt;ng-content&gt; and its powerful features like single projection multiple projection, you can design flexible components that simplify your application&#39;s structure.</p><p>Try it in your next Angular project and experience the magic of dynamic component design!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72560febacc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Input and Output: Communication Between Components]]></title>
            <link>https://medium.com/@ss.web/angular-input-and-output-communication-between-components-4d6b2cb44462?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d6b2cb44462</guid>
            <category><![CDATA[event-binding]]></category>
            <category><![CDATA[input-output]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[one-way-data-binding]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 17:18:38 GMT</pubDate>
            <atom:updated>2023-04-04T17:18:38.006Z</atom:updated>
            <content:encoded><![CDATA[<p>In Angular, input and output are two important concepts that allow you to communicate between components. Inputs allow you to pass data from a parent component to a child component, while outputs allow you to emit data from a child component to a parent component. In this blog, we will take a closer look at inputs and outputs in Angular and provide some examples to help you understand how they work.</p><p><strong><em>Input in Angular</em></strong></p><p>Input is a decorator in Angular that allows you to pass data from a parent component to a child component. Inputs are used when you want to pass data from a parent component to a child component in order to change the behavior of the child component.</p><p>Here is an example of how to use input in Angular:</p><pre>import { Component, Input } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;child-component&#39;,<br>  template: `&lt;h1&gt;{{title}}&lt;/h1&gt;`<br>})<br>export class ChildComponent {<br>  @Input() title: string;<br>}</pre><p>In this example, we have created a child component that takes in a title input. The @Input decorator is used to define the input property, which can be passed from the parent component to the child component.</p><p>Here is an example of how to use the child component in a parent component:</p><pre>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;parent-component&#39;,<br>  template: `<br>    &lt;child-component [title]=&quot;myTitle&quot;&gt;&lt;/child-component&gt;<br>  `<br>})<br>export class ParentComponent {<br>  myTitle = &#39;Hello World&#39;;<br>}</pre><p>In this example, we have created a parent component that passes the myTitle variable as an input to the child component using square brackets. The child component will receive the input and display the title.</p><p><strong><em>Output in Angular</em></strong></p><p>Output is a decorator in Angular that allows you to emit events from a child component to a parent component. Outputs are used when you want to send data or events from a child component to a parent component.</p><p>Here is an example of how to use output in Angular:</p><pre>import { Component, Output, EventEmitter } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;child-component&#39;,<br>  template: `<br>    &lt;button (click)=&quot;onButtonClick()&quot;&gt;Click me&lt;/button&gt;<br>  `<br>})<br>export class ChildComponent {<br>  @Output() buttonClick = new EventEmitter&lt;void&gt;();<br><br>  onButtonClick() {<br>    this.buttonClick.emit();<br>  }<br>}</pre><p>In this example, we have created a child component that emits a buttonClick event when the button is clicked. The @Output decorator is used to define the buttonClick event and the EventEmitter is used to emit the event.</p><p>Here is an example of how to use the child component in a parent component:</p><pre>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;parent-component&#39;,<br>  template: `<br>    &lt;child-component (buttonClick)=&quot;onButtonClick()&quot;&gt;&lt;/child-component&gt;<br>  `<br>})<br>export class ParentComponent {<br>  onButtonClick() {<br>    console.log(&#39;Button clicked!&#39;);<br>  }<br>}</pre><p>In this example, we have created a parent component that listens for the buttonClick event emitted by the child component. When the button is clicked in the child component, the onButtonClick method in the parent component is called, which logs ‘Button clicked!’ to the console.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d6b2cb44462" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the useEffect Hook in React]]></title>
            <link>https://medium.com/@ss.web/understanding-the-useeffect-hook-in-react-ab71c50e7380?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab71c50e7380</guid>
            <category><![CDATA[useeffect-hook]]></category>
            <category><![CDATA[useeffect]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 16:51:41 GMT</pubDate>
            <atom:updated>2023-04-04T16:51:41.737Z</atom:updated>
            <content:encoded><![CDATA[<p>React’s useEffect is a hook that allows you to manage the side effects of a component. In this blog, we will take a deep dive into the useEffect hook, including what it is, how it works, and how to use it.</p><p><strong>What is </strong><strong>useEffect?</strong></p><p>useEffect is a hook that allows you to perform side effects in functional components. Side effects are any changes to the application&#39;s state that are not managed by the React framework, such as fetching data from an API, subscribing to events, or updating the DOM.</p><p>The useEffect hook provides a way to manage these side effects in a declarative manner, meaning that you can declare the side effects that you want to perform and let React handle the details of when and how they are executed.</p><p><strong>How does </strong><strong>useEffect work?</strong></p><p>The useEffect hook takes two arguments: a function that performs the side effect and an array of dependencies that determine when the side effect should be executed.</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function MyComponent() {<br>  const [count, setCount] = useState(0);<br><br>  useEffect(() =&gt; {<br>    document.title = `Count: ${count}`;<br>  }, [count]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Count: {count}&lt;/h1&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, we declare a functional component called MyComponent that manages a count state using the useState hook. We also declare a side effect using the useEffect hook that updates the document title to reflect the current count value.</p><p>The second argument to the useEffect hook is an array that contains a single element, the count state. This tells React that the side effect should only be executed when the count state changes.</p><p>When MyComponent is rendered, React will first render the component and then execute the side effect function. In this case, the side effect sets the document title to the current count value.</p><p>If the count state changes, React will re-render the component and execute the side effect function again with the updated count value.</p><p><strong>useEffect with API?</strong></p><p>useEffect is particularly useful for managing side effects in your components. A common use case for useEffect is to make an API call and update the component&#39;s state with the response.</p><p>Here’s an example of how to use useEffect to fetch data from an API:</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function Example() {<br>  const [data, setData] = useState([]);<br><br>  useEffect(() =&gt; {<br>    fetch(&#39;https://api.example.com/data&#39;)<br>      .then(response =&gt; response.json())<br>      .then(data =&gt; setData(data));<br>  }, []);<br><br>  return (<br>    &lt;ul&gt;<br>      {data.map(item =&gt; (<br>        &lt;li key={item.id}&gt;{item.name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>In this example, we use useEffect to make an API call to https://api.example.com/data and update the data state with the response. The second argument to useEffect is an empty array, which tells React to only run the effect once, when the component is mounted.</p><p>Conclusion</p><p>In conclusion, the useEffect hook is a powerful tool for managing the side effects of functional components in React. With useEffect, you can declare the side effects that you want to perform and let React</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab71c50e7380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React: An Introduction to State Management with useState Hook]]></title>
            <link>https://medium.com/@ss.web/react-an-introduction-to-state-management-with-usestate-hook-9dfc52fa2e67?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dfc52fa2e67</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[usestate-hook]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[usestate]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Sun, 02 Apr 2023 13:36:12 GMT</pubDate>
            <atom:updated>2023-04-02T13:36:12.066Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will discuss the basics of using useState hookin React, and how it can help you manage the state of your application.</p><blockquote>What is State in React?</blockquote><p>In React, state refers to the data that drives the behavior of a component. State is used to store information that can change over time, such as user input, network requests, or the status of a particular feature in the application.</p><p>When a component’s state changes, React will automatically update the component to reflect the new state. This allows you to create dynamic user interfaces that respond to user input and other events.</p><blockquote>Using useState in React</blockquote><p>The useState hook is a built-in function in React that allows you to add state to your functional components. Here is a basic example of how to use useState:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useState(0);<br><br>  function handleClick() {<br>    setCount(count + 1);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, we define a Counter component that displays a count and a button. We use the useState hook to add state to the component, and initialize the count state to 0.</p><p>We also define a handleClick function that increments the count state when the button is clicked, and pass it to the onClick event handler of the button.</p><p>Finally, we render the count and button using JSX.</p><p>When the button is clicked, React will call the handleClick function, which updates the count state using the setCount function provided by useState. React will then re-render the component with the updated state, displaying the new count.</p><blockquote><strong>Conclusion:</strong></blockquote><p>The useState hook is a powerful tool in React that allows you to add state to your functional components. By using useState, you can create dynamic and interactive user interfaces that respond to user input and other events.</p><p>In this blog, we covered the basics of using useState in React, and showed how it can be used to create a simple counter application. By understanding how to use useState, you can start building more complex and feature-rich applications with React.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dfc52fa2e67" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with React: Building Modern and Efficient Web Applications]]></title>
            <link>https://medium.com/@ss.web/getting-started-with-react-building-modern-and-efficient-web-applications-33f79ada8ea8?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/33f79ada8ea8</guid>
            <category><![CDATA[usestate]]></category>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Tue, 28 Mar 2023 15:52:44 GMT</pubDate>
            <atom:updated>2023-03-28T15:52:44.356Z</atom:updated>
            <content:encoded><![CDATA[<p>React is a popular JavaScript library that allows developers to build interactive user interfaces for web applications. It was developed by Facebook and is now maintained by a large community of developers. React is known for its high performance, scalability, and simplicity. In this blog post, we will discuss the basics of React and why it has become so popular among developers.</p><p>What is React?</p><p>React is a JavaScript library for building user interfaces. It was first introduced by Facebook in 2011 and has since become one of the most popular libraries for building web applications. React allows developers to build reusable UI components that can be easily rendered and updated when data changes. This makes it easy to create complex user interfaces and manage application state.</p><p>One of the key features of React is its virtual DOM (Document Object Model). The virtual DOM is a lightweight representation of the actual DOM. When data changes, React updates the virtual DOM and then updates the actual DOM with only the changes that were made. This makes React very fast and efficient, especially for applications with large and complex user interfaces.</p><p>Why use React?</p><p>There are several reasons why developers choose to use React for their web applications. Some of the key benefits of React include:</p><ol><li>Easy to Learn: React is a simple and intuitive library that is easy to learn for developers who are familiar with JavaScript. Its modular architecture and declarative syntax make it easy to write clean and maintainable code.</li><li>Reusable Components: React allows developers to build reusable UI components that can be easily reused across different parts of the application. This makes it easy to create complex user interfaces with minimal code.</li><li>Virtual DOM: The virtual DOM makes React very fast and efficient, especially for applications with large and complex user interfaces.</li><li>Large Community: React has a large and active community of developers who contribute to the library and provide support for other developers. This means that there are many resources available for learning and troubleshooting.</li></ol><p>How to use React?</p><p>To use React in your web application, you need to follow these basic steps:</p><ol><li>Set up a development environment: You will need to set up a development environment with Node.js and a code editor such as Visual Studio Code.</li><li>Create a new React project: You can create a new React project using the create-react-app command in the terminal.</li><li>Write React components: You can start building your application by writing React components. Components are reusable UI elements that can be combined to create complex user interfaces.</li><li>Render React components: You can render React components by using the ReactDOM.render method. This method takes two arguments: the component to render and the element in the DOM where the component should be rendered.</li><li>Update data: React components can be updated when data changes. You can update a component by calling the setState method and passing in new data.</li></ol><p>Conclusion</p><p>React is a powerful JavaScript library for building user interfaces for web applications. Its virtual DOM and reusable components make it easy to create complex user interfaces with minimal code. React is easy to learn, has a large community of developers, and is widely used by companies such as Facebook, Instagram, and Airbnb. If you are looking for a modern, efficient, and scalable way to build web applications, React is definitely worth considering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33f79ada8ea8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File Uploading Using Multer]]></title>
            <link>https://medium.com/@ss.web/file-uploading-using-multer-a0abf962be02?source=rss-492d52cc0568------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0abf962be02</guid>
            <category><![CDATA[mongoose]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[file-upload]]></category>
            <category><![CDATA[file-uploading]]></category>
            <category><![CDATA[multer]]></category>
            <dc:creator><![CDATA[Sameer Shukla ]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 16:50:03 GMT</pubDate>
            <atom:updated>2023-03-27T16:50:03.445Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GoPT4ChmkfRACIVljKqT7A.png" /></figure><p>Uploading files is a common requirement in web applications. In a MERN or MEAN stack application, you can use Multer middleware to handle file uploads on the server side. Multer is a Node.js middleware that allows you to handle multipart/form-data, which is typically used for file uploads.</p><p>In this blog post, we will walk through how to implement file upload using Multer in a MERN/MEAN stack application.</p><h3>Setting up the Backend</h3><p>First, we need to set up the backend of our MERN or MEAN stack application. We will be using Express and Multer for handling file uploads.</p><h3>Install Dependencies</h3><p>We will start by creating a new Node.js project and installing the necessary dependencies:</p><p>mkdir file-upload<br>cd file-upload<br>npm init -y<br>npm install express multer mongoose</p><h3>Configure Multer</h3><p>Next, we will configure Multer in our backend code. Create a new file called upload.js in the project root directory, and add the following code:</p><p>const multer = require(‘multer’);</p><p>const storage = multer.diskStorage({<br> destination: (req, file, cb) =&gt; {<br> cb(null, ‘uploads/’);<br> },<br> filename: (req, file, cb) =&gt; {<br> cb(null, Date.now() + ‘-’ + file.originalname);<br> }<br>});</p><p>const upload = multer({ storage });</p><p>module.exports = upload;</p><p>This code defines a storage engine for Multer that specifies where uploaded files should be stored and how they should be named. In this case, we are storing files in the uploads/ directory and using the current timestamp and original filename as the file name.</p><p>We also define a middleware called upload that uses the storage engine. We will use this middleware in our Express routes to handle file uploads.</p><h3>Create a Route for File Upload</h3><p>Now that we have Multer configured, we can create an Express route for handling file uploads. Create a new file called app.js in the project root directory, and add the following code</p><p>const express = require(‘express’);<br>const mongoose = require(‘mongoose’);<br>const upload = require(‘./upload’);</p><p>const app = express();</p><p>mongoose.connect(‘mongodb://localhost/mean-file-upload’, {<br> useNewUrlParser: true,<br> useUnifiedTopology: true<br>}).then(() =&gt; {<br> console.log(‘Connected to MongoDB’);<br>}).catch((err) =&gt; {<br> console.error(err);<br>});</p><p>const schema = new mongoose.Schema({<br> name: String,<br> path: String<br>});</p><p>const File = mongoose.model(‘File’, schema);</p><p>app.post(‘/upload’, upload.single(‘file’), async (req, res) =&gt; {<br> const { originalname, path } = req.file;</p><p>const file = new File({<br> name: originalname,<br> path: path<br> });</p><p>await file.save();</p><p>res.send(‘File uploaded successfully!’);<br>});</p><p>app.listen(3000, () =&gt; {<br> console.log(‘Server started on port 3000’);<br>});</p><p>This code defines an Express route that listens for POST requests to the /upload endpoint. We use the upload.single middleware to handle file uploads, and specify that the uploaded file should be accessed using the file field.</p><p>We also define a schema for our File model using Mongoose, and create a new instance of the File model to store information about the uploaded file in MongoDB.</p><p>When a file is successfully uploaded, the server responds with the message “File uploaded successfully!”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0abf962be02" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>