<?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 Aasif Shaikh on Medium]]></title>
        <description><![CDATA[Stories by Aasif Shaikh on Medium]]></description>
        <link>https://medium.com/@aasifshaikh_68052?source=rss-2a6113dc5491------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZEakasHm4caCHGp90tN8Xg.jpeg</url>
            <title>Stories by Aasif Shaikh on Medium</title>
            <link>https://medium.com/@aasifshaikh_68052?source=rss-2a6113dc5491------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:43:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aasifshaikh_68052/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[Unleashing the Power of React 19: Harnessing New Hooks and Features]]></title>
            <link>https://medium.com/@aasifshaikh_68052/unleashing-the-power-of-react-19-harnessing-new-hooks-and-features-e7302ae046c2?source=rss-2a6113dc5491------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7302ae046c2</guid>
            <dc:creator><![CDATA[Aasif Shaikh]]></dc:creator>
            <pubDate>Thu, 30 May 2024 09:58:30 GMT</pubDate>
            <atom:updated>2024-05-30T09:58:30.476Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fArNJLXZ_FFrH7J6" /></figure><p><strong>Unleashing the Power of React 19: Harnessing New Hooks and Features</strong></p><p>React is one of the most popular library and easy to use that helps you build captivating user interfaces for web applications. Its component-based architecture allows for reusable and efficient UI development.</p><p>React provides us with built- in hooks we can use in our functional component for handling the business logic without using the class based component..</p><p>Hooks introduced in react 16^^ Hooks allowed developers to use state and other React features without using class based components.</p><p>In this blog, I will be discussing React 19, which introduces exciting new features and hooks. The React community has launched this experimental version, inspired by features implemented in the Instagram app. They are actively working on upcoming features and hooks that primarily focus on two major points in React: data fetching and forms. These hooks are designed to enhance the productivity of all React developers, particularly those working on single-page applications (SPAs)</p><p><strong>There are couple features and hooks what I will be introducing in this blog</strong></p><p>1- React Hooks</p><p>2- React Compiler</p><p>3- Optimization</p><p>4- Server components</p><p>5- Web components</p><p>6- Document Metadata</p><p>7- Asset Loading</p><p>Can I use react 19 now?</p><p><strong>Hooks </strong>— -</p><p>React Hooks have been one of the most loved features introduced in the library. You have likely used React’s built-in hooks many times, and perhaps you’ve tried making your own custom hooks, too. Hooks are so popular that they’ve become a React programming pattern.</p><p>In React 19, the way we use <strong>useMemo</strong>, <strong>forwardRef</strong>, <strong>useEffect</strong>, and <strong>useContext </strong>will change. This is mainly because a new hook, use, will be introduced</p><p><strong>useMemo()</strong> :</p><p>In react 19, we wont need to handle unnecessary re-rendering using useMemo and useCallback hooks, compiler will be memoizing by itself</p><p><strong>Before</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qTTOGKShDOKphzM3" /></figure><p><strong>After using react 19</strong> : you wont need to extra hook for memoizing and make code concise and efficient</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M6_qWhgRgUXZ4epL" /></figure><p><strong>forwardRef</strong>()</p><p>ref will be now passed as props rather than using the forwardRef() hook. This will simplify the code. So after React19, you won’t need to use forwardRef()</p><p>Before :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1qUHMO6Cbpgi0RjY" /></figure><p><strong>After</strong>: using react 19, we wont need to use forwordRef() hook we can pass the ref of element as a normal prop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tKSx9Xc0-W-hyo-2" /></figure><p><strong>React 19 Hooks</strong></p><p><strong>use() 👍</strong></p><p>In react 19, community will introduce the use() hook, this hook will help to handle the promises, async await and context, we wont need to use useContext hook</p><p>syntax : const resource = use(promiseResource) or use(contextResource)</p><p><strong>Before </strong>: use() hook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zZt7O8hkkUnqgo68" /></figure><p><strong>After:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i-fUGr1AJ9bmXHAh" /></figure><p><strong>Context:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kz5XLLvg11GN5p7G" /></figure><p>This new use hook has a hidden power: Unlike all other React Hooks, use can be called within loops and conditional statements like if.</p><p><strong>Form Action:</strong> This new feature enables you to pass a function to the action prop of a &lt;form&gt;. React will call this function when the form is submitted</p><p>syntax : <strong>&lt;form action={handleSubmit} /&gt;</strong></p><p>Remember that if you add a &lt;form action&gt; prop in React 18, you get this warning</p><p>Warning: Invalid value for prop action on &lt;form&gt; tag. Either remove it from the element or pass a string or number value to keep it in the DOM.</p><p>Another Hook:</p><p><strong>useActionState</strong>: useActionState is a Hook that allows you to update state based on the result of a form action</p><p>syntax : const [state, formAction] = useActionState(fn, initialState, permalink?);</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VcXQvgKrp7EB9oz3" /></figure><p><strong>useFormStatus():</strong></p><p>useFormStatus lets you know if a parent &lt;form&gt; is currently submitting or has submitted successfully. It can be called from children of the form, and it returns an object with the following properties</p><p>syntax : const { pending, data, method, action } = useFormStatus();</p><p>Let’s see what’s going on here:</p><p><strong>pending</strong>: if the form is in a pending state, then it will be true, otherwise it will be false.</p><p><strong>data</strong>: an object implementing the FormData interface that contains the data the parent &lt;form&gt; is submitting.</p><p><strong>method</strong>: the HTTP method — GET, or POST. By default it will be GET.</p><p><strong>action</strong>: a function reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r_OhQxce5houRXF3" /></figure><p><strong>Note</strong>: forms hooks must be imported from react-dom, not react</p><p><strong>useOptimistic() :</strong> The useOptimistic hook will immediately update the UI assuming the request will succeed. The name is “optimistic” because the user will see the optimistic (success) result of performing an action, even though the action actually takes time to complete</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kZ2RLtF-bFLRIhmT" /></figure><p><strong>React Compiler</strong> : React has already a compiler for converting the react code into vanilla javascript what is the new in react compiler in react 19 then It should be automatically memoized the value, function and component</p><p><strong>Optimizations </strong>— Currently, React doesn’t automatically re-render during the state change. A way to optimise these re-renders is to manually use some hook according to the variables, let say If I memoized the value then we used useMemo() and If I memoized the function then we use useCallback() and for the whole component then we use memo API. As per React’s team, this was a “reasonable manual compromise”. Their vision was to let React manage these re-renders</p><p>In react 19 will provide use automatically memoization then we no need to use these built-In hooks like useMemo(), useCallback() and memo APIs</p><p><strong>Server Components —</strong></p><p>React components have primarily focused on running on the client side. But React is introducing the groundbreaking concept of running components on the server side. If you want to know about server components then you should go through the Next.js documentation. Next Js is a react framework.</p><p>In React 19, server components will be integrated directly into React, bringing a host of advantages:</p><p><strong>SEO</strong>: Server-rendered components enhance search engine optimisation by providing more accessible content to web crawlers.</p><p><strong>Performance Boost</strong>: Server components contribute to faster initial page loads and improved overall performance, particularly for content-heavy applications.</p><p><strong>Server-Side Execution</strong>: Server components enable executing code on the server, making tasks like API calls seamless and efficient.</p><p>By default, all components in React are client-side. Only when using ‘use server’ will the component become a server component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HT1GXAQtmjxkGlWD" /></figure><p>In React 19, you will be using the server component as NextJs</p><p><strong>Web components -</strong></p><p>Web components allow you to create custom components using native HTML, CSS, and JavaScript, seamlessly incorporating them into your web applications as if they were standard HTML tags</p><p>Currently, integrating web components into React isn’t straightforward. Typically, you either need to convert the web component to a React component or install extra packages and write additional code to make web components work with React. This can be frustrating.</p><p>Luckily, React 19 will help you integrate web components into your React code much more easily. If you come across a really useful web component, such as a carousel, you can seamlessly incorporate it into your React projects without the need to convert it into React code</p><p><strong>Document MetaData:</strong></p><p>Elements like “title,” “meta tags,” and “description” are crucial in optimising SEO and ensuring accessibility. In React, where single-page applications are prevalent, managing these elements across different routes can be a bit of a hassle</p><p>we define all meta tags and title inside the index.html and react is single page application then we define all the tags and SEO related script in index.html</p><p>In react 19, we can use the title and meta tags directly in our React components like that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*29bHPqVXxn7zoeys" /></figure><p><strong>Asset Loading:</strong></p><p>React 19 will introduce asset loading, which integrates with Suspense. Suspense allows displaying fallback UI while assets (such as stylesheets, fonts, and scripts and images) are loading</p><p>This feature enhances the user experience by ensuring smoother transitions during resource loading.</p><p><strong>Can I use react 19 now?</strong></p><p>As of now, React 19 features are available in the canary release, which is considered experimental. The React team suggests not using these features for customer or user-facing apps at the moment..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7302ae046c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Signals]]></title>
            <link>https://medium.com/@aasifshaikh_68052/introduction-to-signals-7c7c8d3742e3?source=rss-2a6113dc5491------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c7c8d3742e3</guid>
            <dc:creator><![CDATA[Aasif Shaikh]]></dc:creator>
            <pubDate>Thu, 19 Oct 2023 13:42:45 GMT</pubDate>
            <atom:updated>2023-10-19T13:42:45.905Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b11reWNK0raJJF6saUib1A.jpeg" /></figure><p>Introduction to Signals</p><p>What is Signal?, Why is getting so popular in Angular while is not a new concept or feature for reactive programming languages, Is it replaceable existing concepts like RXJS, observables, I will explain briefly</p><p>Signals are already used in different reactive languages like Solidjs, Preactjs etc.</p><p>Now introduced in angular V16, May 2023, signals only introduced for enhancement and make the application efficient , good performance, A signal is a wrapper around a value that can notify interested the consumer after change detections</p><p>Change detections means, I will explain it with simple example below</p><p>eg.</p><p>Let say..</p><p>let farman = 100 rupess</p><p>let mehtab = 200</p><p>let junaid = 300</p><p>let Sum;</p><p>Sum = 100 + 200 +300 = 600</p><p>after contribution, farman father gives 200 more for contribution now we calculate the sum</p><p>Sum is still 600</p><p>because sum is already loged with value 600 it will not add 100 rupees with existing sum</p><p>But In Signals,</p><p>import {Signals} from “@angular/core”</p><p>farman = Signal&lt;number&gt;(100)</p><p>mehtab = Signal&lt;number&gt;(200)</p><p>junaid = Signal&lt;number&gt;(300)</p><p>@Constructure() {</p><p>const effect = effect (()=&gt; {</p><p>let sum = farman() + mehtab() + junaid()</p><p>return sum</p><p>})</p><p>}</p><p>//if we want to add additional money then signals provide to update signal to update the state</p><p>farman.update(value =&gt; value + 200);</p><p>//now our component is re-render and add this value with existing one</p><p>sum is now 800 rupees</p><p>Why do we used signals</p><p>Signals provide more reactivity and controls over the change detection which does the improve performance and efficiency</p><p>What is Signals</p><p>count = Signal&lt;number&gt;(0)</p><p>count() //read the value</p><p>// Signals are getter functions — calling them reads their value.</p><p>A signal is a wrapper around a value that can notify interested consumers when that value changes. Signals can contain any value from simple primitives to complex data structures.</p><p>like, number, string, boolean, array, objects and so on…</p><p>A signal’s value is always read through a getter function, which allows Angular to track where the signal is used.</p><p>Signals may be either writable or read-only.</p><p>Writable signals are mutable we can change the value of writable while read only signals are immutable we can not change the value of read only signals</p><p>Note: — By default signals are writable</p><p>Uses of Signals</p><p>We can update the value of signals by using thsese functions</p><p>get()</p><p>set()</p><p>update()</p><p>compute()</p><p>mutate()</p><p>effect()</p><p>Let say have count = signal(0)</p><p>Getter Signals</p><p>get() is default behaviour of signal we can read the value of signal with paranthasis</p><p>eg —</p><p>count() // 0 value</p><p>Setter Signals</p><p>set is basically, used for replaced the existing one</p><p>eg —</p><p>count.set(2) //now value is 2</p><p>Update Signals</p><p>use the .update() operation to compute a new value from the previous one</p><p>eg —</p><p>// Increment the count by 1.</p><p>count.update(value =&gt; value + 1);</p><p>Computed signals</p><p>const count: WritableSignal&lt;number&gt; = signal(0);</p><p>const doubleCount: Signal&lt;number&gt; = computed(() =&gt; count() * 2);</p><p>The doubleCount signal depends on count. Whenever count updates, Angular knows that anything which depends on either count or doubleCount needs to update as well.</p><p>Mutate Signals</p><p>type Product = {</p><p>category : string,</p><p>price : number,</p><p>model : string</p><p>}</p><p>const productsData = signal&lt;Product[]&gt;([{category : “MI”, model : “POCOM2 Pro”, price : 12000}])</p><p>productsData.mutate(value =&gt; {</p><p>// Change the first TODO in the array to ‘done: true’ without replacing it.</p><p>value[0].price = 13000;</p><p>});</p><p>Mutate signals is updating the array of object value without replacing the entire array</p><p>Effect Signals</p><p>Signals are synchronous but in effect function we can change it from synchronus to asynchronous.</p><p>Signals are useful because they can notify interested consumers when they change. An effect is an operation that runs whenever one or more signal values change. You can create an effect with the effect function:</p><p>effect(() =&gt; {</p><p>console.log(`The current count is: ${count()}`);</p><p>});</p><p>Effects always run at least once. When an effect runs, it tracks any signal value reads. Whenever any of these signal values change, the effect runs again. Similar to computed signals, effects keep track of their dependencies dynamically, and only track signals which were read in the most recent execution.</p><p>Effects always execute asynchronously, during the change detection process.</p><p>Reading without tracking dependencies —</p><p>Rarely, you may want to execute code which may read signals in a reactive function such as computed or effect without creating a dependency.</p><p>For example, suppose that when doubleCount() changes, the value of a count() should be logged. Creating an effect which reads both signals</p><p>effect(() =&gt; {</p><p>console.log(`User set to `${doubleCount()}` and the counter is {$count()}`);</p><p>});</p><p>This example logs a message when either doubleCount or count changes. However, if the effect should only run when currentUser changes, then the read of counter is only incidental and changes to counter shouldn’t log a new message.</p><p>You can prevent a signal read from being tracked by calling its getter with untracked:</p><p>effect(() =&gt; {</p><p>console.log(`User set to `${doubleCount()}` and the counter is ${untracked(count)}`);</p><p>});</p><p>Re-Rendring</p><p>When we are different types of life cycle method why we used signals we use singals because it only render that specifice part or property that changes, not render the whole component whenever signals value will change it will only re- render the specific part only</p><p>Where can we use signals?</p><p>Use them in components to track local component state</p><p>Use them in directives</p><p>Use them in a service to share state across components</p><p>Read them in a template to display signal values</p><p>Or use them anywhere else in your code</p><p>You can use signals in everywhere where you want</p><p>Scope of signals</p><p>we can not only define the signals inside the component we can also define the signals outside of the component for sharing the states from parent to child component</p><p>1- Locally,</p><p>Locally scope means we only used signals state inside that component not share the state the with children components</p><p>2 Globally</p><p>In global scope, we can share the state from parent component to child component</p><p>Signals Vs Observable — -</p><p>In this diagram first one is signal second one is primitive value and third one is observable(RXJS) RXJS is reactive programming language that provides observables</p><p>let say :;</p><p>count = 1 //primitive value</p><p>count = signal&lt;number&gt;(1) //&lt;type of value number, string , boolean and so on&gt;</p><p>count = from[1] //observables</p><p>console.log(“Answer of normal variable”, count ) //1</p><p>console.log(“Answer of signals”, count()) //1</p><p>console.log(Answer of observable”, count.subscribe((value) =&gt; value ) //1</p><p>We consume the value of observables we used subscribe functions and re-render this value to after change detections then pass it to life cycle methods like OnChanges()</p><p>eg</p><p>constructor() {</p><p>//it runs only once after first initilizations</p><p>ngOnInit() {</p><p>this.logIt(‘OnInit’);</p><p>}</p><p>// ngOnChnages runs after every change detections</p><p>ngOnChnages(){</p><p>console.log(this.count)</p><p>}</p><p>}</p><p>Note: Ng is nothing but short form of angular</p><p>Advance Topics</p><p>Angular And RXJS Vision</p><p>The sub-RFC 4 proposal sparked a Discussion about the possibilities of integrating Angular Signals with Observables. It all comes down to whether Angular Signals should adopt globally understood common interop</p><p>Ben Lesh (RXJS Author) thinks that making signals fit observable chains directly is a good idea, stating that Signals inherently possess a time dimension that makes them well-suited for this. By adopting common interop points, Angular Signals could achieve better compatibility across various platforms</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c7c8d3742e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>