<?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 Matteo Baratella on Medium]]></title>
        <description><![CDATA[Stories by Matteo Baratella on Medium]]></description>
        <link>https://medium.com/@mattbara?source=rss-c3d897a7fb23------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VWSNss18zcP7DqrT</url>
            <title>Stories by Matteo Baratella on Medium</title>
            <link>https://medium.com/@mattbara?source=rss-c3d897a7fb23------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:28:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mattbara/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[Mastering Micro-Frontends: Vertical vs. Horizontal Architectures Unveiled!]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/mastering-micro-frontends-vertical-vs-horizontal-architectures-unveiled-5ff793aaec14?source=rss-c3d897a7fb23------2"><img src="https://cdn-images-1.medium.com/max/2560/1*nEjPLrVNIWfC1X8iUGY4lQ.png" width="2560"></a></p><p class="medium-feed-snippet">Micro-frontends have emerged as a powerful architectural pattern in modern web development, allowing teams to break down monolithic&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/mastering-micro-frontends-vertical-vs-horizontal-architectures-unveiled-5ff793aaec14?source=rss-c3d897a7fb23------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/mastering-micro-frontends-vertical-vs-horizontal-architectures-unveiled-5ff793aaec14?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ff793aaec14</guid>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[vertical-architecture]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[horizontal-architecture]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Mon, 13 May 2024 07:31:49 GMT</pubDate>
            <atom:updated>2024-05-14T01:12:09.355Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Understanding HTML Streaming and Shadow DOM in Horizontal Micro-Frontend Architecture]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/understanding-html-streaming-and-shadow-dom-in-horizontal-micro-frontend-architecture-51cdada138f5?source=rss-c3d897a7fb23------2"><img src="https://cdn-images-1.medium.com/max/2560/1*ECGSIIGKFTIkpp8QIlW8rA.png" width="2560"></a></p><p class="medium-feed-snippet">In the realm of web development, the concept of micro-frontends has gained significant traction due to its ability to break down&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/understanding-html-streaming-and-shadow-dom-in-horizontal-micro-frontend-architecture-51cdada138f5?source=rss-c3d897a7fb23------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/understanding-html-streaming-and-shadow-dom-in-horizontal-micro-frontend-architecture-51cdada138f5?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/51cdada138f5</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[shadow-dom]]></category>
            <category><![CDATA[html-streaming]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Fri, 10 May 2024 09:59:15 GMT</pubDate>
            <atom:updated>2024-05-13T00:10:46.039Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Elevating React App Security: A Comprehensive Guide to Advanced Authentication with MFA and JWT]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/elevating-react-app-security-a-comprehensive-guide-to-advanced-authentication-with-mfa-and-jwt-c5cd4591a0f6?source=rss-c3d897a7fb23------2"><img src="https://cdn-images-1.medium.com/max/1280/1*AllNR0yA0kY24JlyJs9mDQ.png" width="1280"></a></p><p class="medium-feed-snippet">Security in React applications is non-negotiable, and while Single Sign-On (SSO) serves as a baseline, delving into advanced&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/elevating-react-app-security-a-comprehensive-guide-to-advanced-authentication-with-mfa-and-jwt-c5cd4591a0f6?source=rss-c3d897a7fb23------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/elevating-react-app-security-a-comprehensive-guide-to-advanced-authentication-with-mfa-and-jwt-c5cd4591a0f6?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5cd4591a0f6</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[jwt-token]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[2fa]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Thu, 07 Mar 2024 20:35:44 GMT</pubDate>
            <atom:updated>2024-05-13T00:11:59.238Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Revolutionizing React: A Deep Dive into Concurrent Rendering and Concurrent Features with…]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/revolutionizing-react-a-deep-dive-into-concurrent-rendering-and-concurrent-features-with-c9aa255834a7?source=rss-c3d897a7fb23------2"><img src="https://cdn-images-1.medium.com/max/1920/1*SZZ11symhy8oUWnr_uja9w.png" width="1920"></a></p><p class="medium-feed-snippet">React, the beloved JavaScript library for building user interfaces, continues to evolve with each new release. React 18 represents a&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/revolutionizing-react-a-deep-dive-into-concurrent-rendering-and-concurrent-features-with-c9aa255834a7?source=rss-c3d897a7fb23------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/revolutionizing-react-a-deep-dive-into-concurrent-rendering-and-concurrent-features-with-c9aa255834a7?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9aa255834a7</guid>
            <category><![CDATA[concurrent-rendering]]></category>
            <category><![CDATA[react-18-new-features]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[concurrent-features]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Fri, 15 Sep 2023 10:10:45 GMT</pubDate>
            <atom:updated>2023-09-18T10:41:12.588Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Implementing Single Sign-On (SSO) for Multiple React Apps: A Comprehensive Guide]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/implementing-single-sign-on-sso-for-multiple-react-apps-a-comprehensive-guide-7f792e8d6576?source=rss-c3d897a7fb23------2"><img src="https://cdn-images-1.medium.com/max/1920/1*RJRkaC_4C64hvf4XDJ0F1w.png" width="1920"></a></p><p class="medium-feed-snippet">In today&#x2019;s interconnected digital landscape, users expect seamless experiences when navigating between various web applications.</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/implementing-single-sign-on-sso-for-multiple-react-apps-a-comprehensive-guide-7f792e8d6576?source=rss-c3d897a7fb23------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/implementing-single-sign-on-sso-for-multiple-react-apps-a-comprehensive-guide-7f792e8d6576?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f792e8d6576</guid>
            <category><![CDATA[sso]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 10:40:02 GMT</pubDate>
            <atom:updated>2024-09-26T12:39:39.935Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Exploring the Power of TC39 JavaScript Methods for Supercharging React]]></title>
            <link>https://blog.stackademic.com/exploring-the-power-of-tc39-javascript-methods-for-supercharging-react-a-todo-list-implementation-26d9406bdc12?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/26d9406bdc12</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[tc39]]></category>
            <category><![CDATA[javascript-method]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 09:10:25 GMT</pubDate>
            <atom:updated>2023-08-21T15:50:02.066Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Todo List Implementation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xmnrqiVy899Bjez5Pv2afw.png" /></figure><p>In the ever-evolving world of web development, staying updated with the latest advancements is crucial for creating efficient and maintainable code. JavaScript, being the backbone of modern web applications, continually receives updates to improve its capabilities. One of the recent additions to the JavaScript ecosystem is the introduction of new TC39 methods that seamlessly integrate with popular libraries like React. In this article, we’ll delve into three new TC39 methods — .with, .toSpliced, and .toSorted – and demonstrate their usage through a practical example of building a dynamic todo list application in React.</p><p><strong>TC39 Methods: Enhancing JavaScript Functionality</strong></p><p>The TC39 organization is responsible for the evolution of the JavaScript programming language. Over the years, TC39 has introduced various features and methods to improve the language’s capabilities and usability. The recent additions of .with, .toSpliced, and .toSorted methods bring a new level of expressiveness and efficiency to JavaScript code.</p><p><strong>Building a Todo List with React and TC39 Methods</strong></p><p>Let’s dive into building a todo list application using these new TC39 methods in conjunction with React. We’ll start with a basic todo list and gradually integrate the TC39 methods to showcase their benefits.</p><p><strong>1. Creating the Basic Todo List</strong></p><p>Before we integrate the TC39 methods, let’s create a basic todo list using React. We’ll start by setting up a new React application and creating the necessary components.</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function TodoApp() {<br>  const [todos, setTodos] = useState([]);<br>  const [newTodo, setNewTodo] = useState(&#39;&#39;);<br><br>  const addTodo = () =&gt; {<br>    if (newTodo.trim() !== &#39;&#39;) {<br>      setTodos([...todos, newTodo]);<br>      setNewTodo(&#39;&#39;);<br>    }<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Todo List&lt;/h1&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        value={newTodo}<br>        onChange={(e) =&gt; setNewTodo(e.target.value)}<br>      /&gt;<br>      &lt;button onClick={addTodo}&gt;Add&lt;/button&gt;<br>      &lt;ul&gt;<br>        {todos.map((todo, index) =&gt; (<br>          &lt;li key={index}&gt;{todo}&lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default TodoApp;</pre><p>This basic todo list application allows users to add and display todos. Now, let’s enhance it using the new TC39 methods.</p><p><strong>2. Leveraging TC39 Methods for Todo List Manipulation</strong></p><p><strong><em>A. The </em></strong><strong><em>.with Method</em></strong></p><p>The .with method allows us to perform operations on an object or array within a local scope. In our todo list, we can use .with to temporarily modify the todos array.</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function TodoApp() {<br>  const [todos, setTodos] = useState([]);<br>  const [newTodo, setNewTodo] = useState(&#39;&#39;);<br><br>  const addTodo = () =&gt; {<br>    if (newTodo.trim() !== &#39;&#39;) {<br>      setTodos([...todos, newTodo]);<br>      setNewTodo(&#39;&#39;);<br>    }<br>  };<br><br>  const removeTodo = (index) =&gt; {<br>    todos.with((tempTodos) =&gt; {<br>      tempTodos.splice(index, 1);<br>      setTodos(tempTodos);<br>    });<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Todo List&lt;/h1&gt;<br>      {/* ... */}<br>      &lt;ul&gt;<br>        {todos.map((todo, index) =&gt; (<br>          &lt;li key={index}&gt;<br>            {todo}<br>            &lt;button onClick={() =&gt; removeTodo(index)}&gt;Remove&lt;/button&gt;<br>          &lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default TodoApp;</pre><p>In the example above, we’ve used .with to create a local scope for the todos array. This allows us to safely modify the array using the .splice method without directly altering the original state.</p><p><strong><em>B. The </em></strong><strong><em>.toSpliced Method</em></strong></p><p>The .toSpliced method provides a cleaner way to remove elements from an array. We&#39;ll refactor our removeTodo function using .toSpliced.</p><pre>// ...<br>const removeTodo = (index) =&gt; {<br>  setTodos(todos.toSpliced(index, 1));<br>};<br>// ...</pre><p>By using .toSpliced, we achieve the same functionality with more concise code.</p><p><strong><em>C. The </em></strong><strong><em>.toSorted Method</em></strong></p><p>Next, let’s implement sorting functionality for our todo list using the .toSorted method. This method simplifies the process of sorting arrays.</p><pre>// ...<br>const sortTodos = () =&gt; {<br>  setTodos(todos.toSorted());<br>};<br>// ...</pre><p><strong>Conclusion</strong></p><p>The introduction of new TC39 methods .with, .toSpliced, and .toSorted brings enhanced functionality and readability to JavaScript code. By integrating these methods into a React application, such as our dynamic to-do list, developers can streamline operations and write more concise and maintainable code. As JavaScript continues to evolve, staying informed about such additions empowers developers to create efficient and robust web applications.</p><p><em>Thank you for reading until the end. Please consider following the writer and this publication. Visit </em><a href="https://stackademic.com/"><em>Stackademic</em></a><em> to find out more about how we are democratizing free programming education around the world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26d9406bdc12" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/exploring-the-power-of-tc39-javascript-methods-for-supercharging-react-a-todo-list-implementation-26d9406bdc12">Exploring the Power of TC39 JavaScript Methods for Supercharging React</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring React Server Components]]></title>
            <link>https://blog.stackademic.com/exploring-react-server-components-a-new-paradigm-for-enhanced-performance-and-developer-experience-a0388c390928?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0388c390928</guid>
            <category><![CDATA[frontend-performance]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react-server-component]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Fri, 04 Aug 2023 12:46:11 GMT</pubDate>
            <atom:updated>2023-08-21T08:01:37.526Z</atom:updated>
            <content:encoded><![CDATA[<h4>A New Paradigm for Enhanced Performance and Developer Experience</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a-i9KfJALoqbbFnAy_k3AA.png" /></figure><p>In the ever-evolving world of web development, staying abreast of the latest technologies and trends is essential to ensure the creation of performant and user-friendly applications. One of the recent advancements that has captured the attention of the React community is the introduction of React Server Components. This article delves into the world of React Server Components, providing insightful code examples and discussing their pros and cons.</p><h4>What are React Server Components?</h4><p>React Server Components are a groundbreaking addition to the React ecosystem that aims to address some of the long-standing challenges in web application development, particularly related to performance and code splitting. They are an experimental feature and are not yet fully released as of the time of writing, but they offer a promising glimpse into the future of React development.</p><p>At a high level, React Server Components enable developers to declaratively render components on the server and stream them to the client. This approach has the potential to drastically reduce the initial load time of web applications and improve the user experience, especially for users on slower network connections or less powerful devices.</p><h4>How React Server Components Work</h4><p>React Server Components work by breaking down a traditional React component into two parts: a server component and a client component. The server component is responsible for rendering the component on the server and generating the initial HTML markup. This markup is then streamed to the client, allowing the user to see meaningful content much faster than waiting for the entire JavaScript bundle to load.</p><p>Here’s a basic example of how a React Server Component might look:</p><pre>// Server Component<br>import { serverComponent } from &#39;react-server-component&#39;;<br><br>function ServerCounter() {<br>  const count = useCounter(); // Some custom hook to manage state<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;Server Counter&lt;/h2&gt;<br>      &lt;p&gt;{count}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default serverComponent(ServerCounter);</pre><pre>// Client Component<br>import { client } from &#39;react-server-component&#39;;<br><br>function ClientCounter() {<br>  return &lt;ServerCounter /&gt;;<br>}<br><br>export default client(ClientCounter);</pre><p>In this example, the ServerCounter component is rendered on the server and streamed to the client, reducing the initial loading time. The ClientCounter component acts as a placeholder on the client side and seamlessly takes over once the server component is hydrated.</p><h4>Pros of React Server Components</h4><ol><li>Improved Initial Load Time: By rendering components on the server and streaming them to the client, React Server Components can significantly reduce the time users spend waiting for content to appear on their screens.</li><li>Enhanced Performance: Server Components have the potential to optimize performance for a wide range of devices and network conditions, making your application more accessible and user-friendly.</li><li>Simplified Code Splitting: Server Components naturally encourage better code splitting, as components can be loaded on-demand on the server and sent to the client only when needed.</li><li>Developer Experience: React Server Components align with familiar React patterns, making it relatively easy for developers to adopt and integrate them into their existing projects.</li></ol><h4>Cons of React Server Components</h4><ol><li>Complexity: While the concept is intriguing, working with server components introduces a level of complexity that might be challenging for less experienced developers.</li><li>Experimental Nature: As of now, React Server Components are experimental, which means they are not yet suitable for production use. This might deter some developers from adopting them until they are more stable.</li><li>Learning Curve: Developers will need to learn how to manage both server and client components, which can add to the learning curve, especially for teams unfamiliar with server-side rendering.</li><li>Limited Browser Support: Since React Server Components are a new feature, browser support might be limited initially. This could potentially impact the range of users who can benefit from this technology.</li></ol><h4>Conclusion</h4><p>React Server Components represent an exciting evolution in the world of React development. By allowing components to be rendered on the server and streamed to the client, they hold the promise of significantly improving initial load times and overall performance.</p><p>While they come with certain complexities and are still in the experimental phase, they offer a glimpse into a more streamlined and efficient future for web applications. As they continue to mature and gain wider adoption, React Server Components have the potential to revolutionize the way we build and deliver web experiences.</p><p><em>Thank you for reading until the end. Please consider following the writer and this publication. Visit </em><a href="https://stackademic.com/"><em>Stackademic</em></a><em> to find out more about how we are democratizing free programming education around the world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0388c390928" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/exploring-react-server-components-a-new-paradigm-for-enhanced-performance-and-developer-experience-a0388c390928">Exploring React Server Components</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing Responsive Design with Container Queries and Dynamic Viewport Units]]></title>
            <link>https://blog.stackademic.com/embracing-responsive-design-with-container-queries-scoped-css-and-dynamic-viewport-units-1e9b9b3a2c81?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e9b9b3a2c81</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[css3]]></category>
            <category><![CDATA[css3-dynamic-queries]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Thu, 03 Aug 2023 11:29:05 GMT</pubDate>
            <atom:updated>2023-08-21T08:08:05.925Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r_8pI_VkXaA_zJRoS3dR_Q.png" /></figure><p>As the demand for responsive web design continues to grow, CSS3 has introduced several exciting features that empower developers to create more adaptive and context-aware layouts. In this article, we’ll explore Container Queries, Flexbox, Grid Gap Units, and Dynamic Viewport Units. We will provide code examples to demonstrate their practical use cases and highlight browser support for each feature.</p><ol><li><strong>Container Queries</strong></li></ol><p>Container Queries allow developers to define CSS rules based on the size of the container element rather than the viewport. This feature provides more granular control over styles for specific components, making them more responsive within their parent containers.</p><pre>/* Example 1: */<br>@container (min-width: 300px) {<br>  .component {<br>    font-size: 1.5rem;<br>  }<br>}<br><br>/* Example 2: */<br>@container (max-width: 768px) {<br>  .sidebar {<br>    display: none;<br>  }<br>}</pre><p><em>Browser Support:</em> As of the latest update, Container Queries are still in the experimental stage and may not be fully supported across all browsers. It’s essential to check for the latest updates and consider fallback solutions for unsupported browsers.</p><p>2. <strong>Flexbox and Grid Gap Units</strong></p><p>Flexbox and Grid Gap Units introduce new gap properties to manage spacing between elements within layouts, bringing more simplicity and efficiency to the styling process.</p><pre>/* Flexbox Example */<br>.container {<br>  display: flex;<br>  gap: 10px;<br>  justify-content: space-between;<br>}<br><br>/* Grid Example */<br>.grid-container {<br>  display: grid;<br>  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));<br>  gap: 20px;<br>}</pre><p><em>Browser Support:</em> Flexbox and Grid Gap Units are well-supported in modern browsers, including Chrome, Firefox, Safari, and Edge.</p><p>3. <strong>Dynamic Viewport Units</strong></p><p>Dynamic Viewport Units enable developers to create responsive designs based on various viewport measurements, such as the:</p><ul><li>viewport height (svh),</li><li>viewport width (svw),</li><li>layout viewport height (lvh),</li><li>layout viewport width (lvw),</li><li>visual viewport height (dvh),</li><li>visual viewport width (dvw)</li></ul><pre>/* Example 1: Using svw and svh */<br>.element {<br>  width: 50svw;<br>  height: 30svh;<br>}<br><br>/* Example 2: Using lvh and lvw */<br>.container {<br>  width: 80lvw;<br>  height: 40lvh;<br>}</pre><p><em>Browser Support:</em> Dynamic Viewport Units have good support in modern browsers, including Chrome, Firefox, Safari, and Edge.</p><p><strong>Conclusion</strong></p><p>Container Queries, Flexbox and Grid Gap Units, and Dynamic Viewport Units are powerful CSS3 features that enable developers to create more responsive and adaptable web layouts. While some features are still experimental and might have limited browser support, they represent the future of web design and development.</p><p>By utilizing these innovative features alongside progressive enhancement techniques, developers can build websites that gracefully adapt to various screen sizes and devices, providing users with a seamless and engaging experience. Remember to stay up-to-date with the latest browser support and consider fallback strategies to ensure your projects reach a broader audience.</p><p><em>Thank you for reading until the end. Please consider following the writer and this publication. Visit </em><a href="https://stackademic.com/"><em>Stackademic</em></a><em> to find out more about how we are democratizing free programming education around the world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e9b9b3a2c81" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/embracing-responsive-design-with-container-queries-scoped-css-and-dynamic-viewport-units-1e9b9b3a2c81">Embracing Responsive Design with Container Queries and Dynamic Viewport Units</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Separation of Concerns, Business Logic, and Dependency Injection in React Applications]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.stackademic.com/separation-of-concerns-business-logic-and-dependency-injection-in-react-applications-b3db813bb570?source=rss-c3d897a7fb23------2"><img src="https://cdn-images-1.medium.com/max/1200/1*CeL0R_w6Zko2ROqaGxv66A.png" width="1200"></a></p><p class="medium-feed-snippet">Modern web development demands well-structured applications that are easy to maintain, extend, and test. Achieving these goals requires&#x2026;</p><p class="medium-feed-link"><a href="https://blog.stackademic.com/separation-of-concerns-business-logic-and-dependency-injection-in-react-applications-b3db813bb570?source=rss-c3d897a7fb23------2">Continue reading on Stackademic »</a></p></div>]]></description>
            <link>https://blog.stackademic.com/separation-of-concerns-business-logic-and-dependency-injection-in-react-applications-b3db813bb570?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3db813bb570</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[business-logic]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[separation-of-concerns]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 22:15:19 GMT</pubDate>
            <atom:updated>2023-08-21T08:06:53.721Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[SOLID Principles and Dependency Injection in React & TypeScript]]></title>
            <link>https://blog.stackademic.com/solid-principles-and-dependency-injection-in-react-typescript-1be7084e3a6c?source=rss-c3d897a7fb23------2</link>
            <guid isPermaLink="false">https://medium.com/p/1be7084e3a6c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Matteo Baratella]]></dc:creator>
            <pubDate>Wed, 26 Jul 2023 09:15:12 GMT</pubDate>
            <atom:updated>2023-08-21T08:05:31.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y1dyZMLpnHXdKWj77BJsfQ.png" /></figure><p>The SOLID principles are a set of five design principles that aid in creating maintainable and scalable software. When applied to React applications, they help in building modular, flexible, and testable code. Additionally, dependency injection is a technique that enhances the flexibility and reusability of components by decoupling them from their dependencies. In this article, we will explore each SOLID principle, understand how they apply to React function components and delve into the benefits of using dependency injection in React applications.</p><ol><li><strong>Single Responsibility Principle (SRP)</strong></li></ol><p>The SRP states that a component or module should have only one reason to change. In the context of React function components, this means that each component should be responsible for a single concern or functionality.</p><p>Example: Consider a simple React component that displays a user’s profile:</p><pre>// UserProfile.tsx<br>import React from &#39;react&#39;;<br><br>interface UserProfileProps {<br>  user: User;<br>}<br><br>const UserProfile: React.FC&lt;UserProfileProps&gt; = ({ user }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{user.name}&lt;/h1&gt;<br>      &lt;p&gt;Email: {user.email}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>In this example, the UserProfile component follows the SRP by focusing solely on rendering the user&#39;s profile data.</p><p>Pros:</p><ul><li>Improved code maintainability and readability.</li><li>Easier to identify and fix issues as each component has a clear purpose.</li><li>Facilitates reusability.</li></ul><p>Cons:</p><ul><li>This may lead to a higher number of smaller components, which might be overwhelming for very simple cases.</li></ul><p>2. <strong>Open/Closed Principle (OCP)</strong></p><p>The OCP suggests that a component should be open for extension but closed for modification. This means that you can enhance the behavior of a component without modifying its existing code.</p><p>Example: Building upon the previous example, let’s add a feature to display the user’s avatar using Gravatar:</p><pre>// UserProfile.tsx<br>import React from &#39;react&#39;;<br>import { getGravatarUrl } from &#39;./utils&#39;;<br><br>interface UserProfileProps {<br>  user: User;<br>  showAvatar: boolean;<br>}<br><br>const UserProfile: React.FC&lt;UserProfileProps&gt; = ({ user, showAvatar }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      {showAvatar &amp;&amp; &lt;img src={getGravatarUrl(user.email)} alt=&quot;Avatar&quot; /&gt;}<br>      &lt;h1&gt;{user.name}&lt;/h1&gt;<br>      &lt;p&gt;Email: {user.email}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>Now, we’ve extended the component to optionally show the user’s avatar based on the showAvatar prop.</p><p>Pros:</p><ul><li>Extending functionality becomes easier without impacting existing code.</li><li>Encourages reusable and pluggable components.</li></ul><p>Cons:</p><ul><li>Implementing the OCP might require some initial design and planning.</li></ul><p>3. <strong>Liskov Substitution Principle (LSP)</strong></p><p>The LSP emphasizes that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program.</p><p>Example: Let’s create a User interface and two classes, RegularUser and PremiumUser, which both implement the User interface:</p><pre>// interfaces.ts<br>interface User {<br>  name: string;<br>  email: string;<br>  // Additional properties common to all users<br>}<br><br>// RegularUser.ts<br>export class RegularUser implements User {<br>  constructor(public name: string, public email: string) {}<br>  // RegularUser-specific methods<br>}<br><br>// PremiumUser.ts<br>export class PremiumUser implements User {<br>  constructor(public name: string, public email: string) {}<br>  // PremiumUser-specific methods<br>}</pre><p>Now, we can use these classes in our UserProfile component:</p><pre>// UserProfile.tsx<br>import React from &#39;react&#39;;<br>import { RegularUser, PremiumUser } from &#39;./interfaces&#39;;<br><br>interface UserProfileProps {<br>  user: RegularUser | PremiumUser;<br>}<br><br>const UserProfile: React.FC&lt;UserProfileProps&gt; = ({ user }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{user.name}&lt;/h1&gt;<br>      &lt;p&gt;Email: {user.email}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>Pros:</p><ul><li>Enables polymorphism and interchangeability of objects.</li><li>Simplifies code reuse by utilizing shared interfaces.</li></ul><p>Cons:</p><ul><li>Incorrect implementation of subclasses may lead to unexpected behavior.</li></ul><p>4. <strong>Interface Segregation Principle (ISP)</strong></p><p>The ISP states that a client should not be forced to depend on interfaces it does not use. In other words, a component should not be overwhelmed with a large interface that contains unnecessary methods.</p><p>Example: Consider an interface for a user profile that includes both personal and contact information:</p><pre>// UserProfile.tsx<br>import React from &#39;react&#39;;<br><br>interface UserProfile {<br>  name: string;<br>  email: string;<br>  phone: string;<br>  address: string;<br>}<br><br>const UserProfileComponent: React.FC&lt;UserProfile&gt; = ({ name, email }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{name}&lt;/h1&gt;<br>      &lt;p&gt;Email: {email}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>In this example, the UserProfile interface contains extra fields that may not be relevant to all use cases.</p><p>To adhere to the ISP, we should split the interface into more specific ones:</p><pre>// interfaces.ts<br>interface PersonalInfo {<br>  name: string;<br>  email: string;<br>}<br><br>interface ContactInfo {<br>  phone: string;<br>  address: string;<br>}<br><br>// UserProfile.tsx<br>import React from &#39;react&#39;;<br>import { PersonalInfo } from &#39;./interfaces&#39;;<br><br>const UserProfileComponent: React.FC&lt;PersonalInfo&gt; = ({ name, email }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{name}&lt;/h1&gt;<br>      &lt;p&gt;Email: {email}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>Pros:</p><ul><li>Reduces coupling between components.</li><li>Prevents components from relying on unnecessary or unrelated functionality.</li></ul><p>Cons:</p><ul><li>Requires careful analysis and design to identify proper interfaces.</li></ul><p>5. <strong>Dependency Inversion Principle (DIP)</strong></p><p>The DIP states that high-level modules should not depend on low-level modules. Instead, both should depend on abstractions. Additionally, abstractions should not depend on details; details should depend on abstractions.</p><p>Example: Suppose we have a simple React component responsible for fetching user data:</p><pre>// UserDataService.ts<br>export class UserDataService {<br>  async getUserData(userId: string): Promise&lt;User&gt; {<br>    // Fetch user data from an API<br>  }<br>}<br><br>// UserProfile.tsx<br>import React, { useEffect, useState } from &#39;react&#39;;<br>import { UserDataService } from &#39;./UserDataService&#39;;<br><br>const UserProfile: React.FC&lt;{ userId: string }&gt; = ({ userId }) =&gt; {<br>  const [user, setUser] = useState&lt;User | null&gt;(null);<br><br>  useEffect(() =&gt; {<br>    const fetchData = async () =&gt; {<br>      const userService = new UserDataService();<br>      const userData = await userService.getUserData(userId);<br>      setUser(userData);<br>    };<br><br>    fetchData();<br>  }, [userId]);<br><br>  return (<br>    &lt;div&gt;<br>      {user ? (<br>        &lt;div&gt;<br>          &lt;h1&gt;{user.name}&lt;/h1&gt;<br>          &lt;p&gt;Email: {user.email}&lt;/p&gt;<br>        &lt;/div&gt;<br>      ) : (<br>        &lt;p&gt;Loading...&lt;/p&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>};</pre><p>In this example, the UserProfile component directly creates an instance of UserDataService, violating the DIP.</p><p>To adhere to the DIP, we should use dependency injection to provide the service instance from the parent component:</p><pre>// UserProfile.tsx<br>import React, { useEffect, useState } from &#39;react&#39;;<br>import { UserDataService } from &#39;./UserDataService&#39;;<br><br>interface UserProfileProps {<br>  userId: string;<br>  userService: UserDataService;<br>}<br><br>const UserProfile: React.FC&lt;UserProfileProps&gt; = ({ userId, userService }) =&gt; {<br>  const [user, setUser] = useState&lt;User | null&gt;(null);<br><br>  useEffect(() =&gt; {<br>    const fetchData = async () =&gt; {<br>      const userData = await userService.getUserData(userId);<br>      setUser(userData);<br>    };<br><br>    fetchData();<br>  }, [userId, userService]);<br><br>  return (<br>    &lt;div&gt;<br>      {user ? (<br>        &lt;div&gt;<br>          &lt;h1&gt;{user.name}&lt;/h1&gt;<br>          &lt;p&gt;Email: {user.email}&lt;/p&gt;<br>        &lt;/div&gt;<br>      ) : (<br>        &lt;p&gt;Loading...&lt;/p&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>};</pre><p>Now, the parent component can inject the UserDataService:</p><pre>import React from &#39;react&#39;;<br>import { UserDataService } from &#39;./UserDataService&#39;;<br>import { UserProfile } from &#39;./UserProfile&#39;;<br><br>const App: React.FC = () =&gt; {<br>  const userService = new UserDataService();<br><br>  return &lt;UserProfile userId=&quot;123&quot; userService={userService} /&gt;;<br>};</pre><p>Pros:</p><ul><li>Promotes loose coupling between components.</li><li>Enhances testability as we can easily mock or stub dependencies during testing.</li><li>Enables more flexibility in switching or customizing dependencies.</li></ul><p>Cons:</p><ul><li>Slightly more boilerplate code for setting up and passing dependencies.</li></ul><p><strong>Conclusion</strong></p><p>By understanding and applying the SOLID principles in React function components, we can create well-organized, maintainable, and scalable applications. Additionally, employing dependency injection enhances the flexibility and testability of our components, making our codebase more robust and future-proof. While it may require some extra effort, the benefits of following SOLID principles and using dependency injection significantly outweigh the downsides in the long run.</p><p>Happy coding!</p><p><em>Thank you for reading until the end. Please consider following the writer and this publication. Visit </em><a href="https://stackademic.com/"><em>Stackademic</em></a><em> to find out more about how we are democratizing free programming education around the world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1be7084e3a6c" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/solid-principles-and-dependency-injection-in-react-typescript-1be7084e3a6c">SOLID Principles and Dependency Injection in React &amp; TypeScript</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>