<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Module-2 on Ghafoor's Personal Blog</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/</link><description>Recent content in Module-2 on Ghafoor's Personal Blog</description><generator>Hugo</generator><language>en</language><managingEditor>noreply@example.com (AG Sayyed)</managingEditor><webMaster>noreply@example.com (AG Sayyed)</webMaster><copyright>Copyright © 2024-2026 AG Sayyed. All Rights Reserved.</copyright><atom:link href="http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/index.xml" rel="self" type="application/rss+xml"/><item><title>Module Summary</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/009-module-summry/</link><pubDate>Tue, 29 Jul 2025 10:15:14 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/009-module-summry/</guid><description>&lt;p class="lead text-primary"&gt;
This document summarizes the essential concepts from Module 2, including arrays in components, the virtual DOM, and styling approaches in React. It provides a structured overview of how these features enable dynamic, efficient, and maintainable user interfaces.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="module-summary"&gt;Module Summary&lt;/h2&gt;
&lt;h3 id="function-components"&gt;Function Components&lt;/h3&gt;
&lt;p&gt;Function components are the primary building blocks in React, defined as JavaScript functions that return JSX. They are simple, reusable, and support hooks for state and side effects.&lt;/p&gt;</description></item><item><title>Styles</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/008-styles/</link><pubDate>Tue, 29 Jul 2025 09:27:38 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/008-styles/</guid><description>&lt;h2 id="styles-in-react"&gt;Styles in React&lt;/h2&gt;
&lt;p&gt;In React, styles can be applied to components in various ways, including inline styles, CSS stylesheets, CSS modules, and styled-components. Each method has its own use cases and advantages.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id="inline-styles"&gt;Inline Styles&lt;/h3&gt;
&lt;p&gt;Inline styles are defined directly within the component using a JavaScript object. This method is useful for dynamic styles that depend on component state or props.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-jsx" data-lang="jsx"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 2&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="kr"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 3&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;blue&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 4&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;backgroundColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;lightgray&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 5&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;padding&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;10px&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 6&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;borderRadius&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;5px&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 7&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 8&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 9&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;}&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;10&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;11&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// Or
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;12&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;13&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;14&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;15&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;16&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;blue&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;17&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;backgroundColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;lightgray&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;18&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;padding&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;10px&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;19&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="nx"&gt;borderRadius&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;5px&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;20&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;21&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;22&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;margin&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}}&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;23&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;24&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;25&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Inline styles are defined as a JavaScript object.&lt;/li&gt;
&lt;li&gt;Property names are written in camelCase (e.g., &lt;code&gt;backgroundColor&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Values are specified as strings.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id="css-modules"&gt;CSS Modules&lt;/h3&gt;
&lt;p&gt;CSS Modules allow you to write CSS that is scoped locally to the component, preventing style conflicts. They are implemented as a file with a &lt;code&gt;.module.css&lt;/code&gt; extension.&lt;/p&gt;</description></item><item><title>Vdom in React</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/007-vdom-in-react/</link><pubDate>Tue, 29 Jul 2025 09:22:38 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/007-vdom-in-react/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers the virtual DOM in React, including its structure, how it optimizes updates, the reconciliation process, and the key differences and advantages over the normal DOM.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-the-dom"&gt;Introduction to the DOM&lt;/h2&gt;
&lt;p&gt;The Document Object Model (DOM) is an interface for web pages that represents HTML as a tree-like structure. Each node in the tree corresponds to elements, attributes, or text in the document. The DOM enables programs to access and manipulate content, structure, and style dynamically.&lt;/p&gt;</description></item><item><title>Arrays in Component</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/006-arrays-in-component/</link><pubDate>Tue, 29 Jul 2025 08:40:18 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/006-arrays-in-component/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers how to declare, traverse, and manage arrays in React components, including state management, rendering lists, and using array methods like map, forEach, and splice for dynamic UIs.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="arrays-in-react-components"&gt;Arrays in React Components&lt;/h2&gt;
&lt;p&gt;Arrays are fundamental data structures in JavaScript, used to store multiple values in a single variable. In React, arrays are essential for managing lists of data and building dynamic user interfaces.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="declaring-and-managing-arrays"&gt;Declaring and Managing Arrays&lt;/h2&gt;
&lt;p&gt;Arrays can be declared using array literal notation:&lt;/p&gt;</description></item><item><title>Component Testing</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/005-component-testing/</link><pubDate>Tue, 29 Jul 2025 08:30:45 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/005-component-testing/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers the fundamentals of testing React components, including the advantages and disadvantages, testing approaches, Arrange-Act-Assert pattern, and popular tools like Jest and React Testing Library.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-component-testing"&gt;Introduction to Component Testing&lt;/h2&gt;
&lt;p&gt;Testing is the process of reviewing how code executes, either line-by-line or through suites that verify application behavior. It ensures that applications work as intended and helps prevent regressions.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="advantages-and-disadvantages-of-testing"&gt;Advantages and Disadvantages of Testing&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Prevents unexpected regressions&lt;/li&gt;
&lt;li&gt;Allows developers to focus on current tasks&lt;/li&gt;
&lt;li&gt;Enables modular construction of complex applications&lt;/li&gt;
&lt;li&gt;Reduces the need for manual verification&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Function Comp Lifecycle</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/004-function-comp-lifecycle/</link><pubDate>Tue, 29 Jul 2025 08:16:33 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/004-function-comp-lifecycle/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers the four phases of the React function component lifecycle—mounting, updating, unmounting, and error handling—explaining how hooks like useState and useEffect enable similar control as class lifecycle methods.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="function-component-lifecycle-in-react"&gt;Function Component Lifecycle in React&lt;/h2&gt;
&lt;p&gt;React function components are the core building blocks for user interfaces. Understanding their lifecycle is essential for managing state, side effects, and cleanup throughout a component’s existence.&lt;/p&gt;
&lt;h3 id="lifecycle-phases-overview"&gt;Lifecycle Phases Overview&lt;/h3&gt;
&lt;p&gt;React function components experience four main phases:&lt;/p&gt;</description></item><item><title>State Management</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/003-state-management/</link><pubDate>Tue, 29 Jul 2025 08:11:02 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/003-state-management/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers state management in React function components, including the useState hook, syntax, and practical examples for managing and updating dynamic data in the UI.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="state-management-in-react-function-components"&gt;State Management in React Function Components&lt;/h2&gt;
&lt;p&gt;State management allows React components to handle data that changes over time. The state of a component determines its behavior and how it renders at any given moment.&lt;/p&gt;
&lt;h3 id="what-is-state"&gt;What is State&lt;/h3&gt;
&lt;p&gt;State refers to the condition or data of a component at a specific time. It holds information that influences the component&amp;rsquo;s behavior and rendering.&lt;/p&gt;</description></item><item><title>Component Composition</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/002-component-composition/</link><pubDate>Tue, 29 Jul 2025 07:54:24 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/002-component-composition/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores how React component composition enables building complex UIs from smaller, reusable function components. It covers abstraction, reusability, hierarchy, props, children, and higher-order components, with practical examples for clarity.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="component-composition-in-react"&gt;Component Composition in React&lt;/h2&gt;
&lt;p&gt;Component composition is the process of combining multiple smaller components to create more complex functionality and larger UI structures. This approach allows developers to build applications using small, focused building blocks.&lt;/p&gt;
&lt;h3 id="principles-of-function-component-composition"&gt;Principles of Function Component Composition&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Abstraction:&lt;/strong&gt; Create reusable components that encapsulate specific UI features, breaking down large interfaces into manageable pieces.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reusability:&lt;/strong&gt; Avoid code duplication by reusing components across different parts of the application.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hierarchy:&lt;/strong&gt; Arrange components in parent-child relationships, supporting modular and organized design.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Props and Children:&lt;/strong&gt; Pass data and even entire components as props or children, enabling flexible composition.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Higher-Order Components (HOCs):&lt;/strong&gt; Write functions that accept components as input or return enhanced components, adding features like state management or logic without modifying the original implementation.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="example-composing-a-blog-post-ui"&gt;Example: Composing a Blog Post UI&lt;/h2&gt;
&lt;p&gt;Below is a practical example demonstrating these principles. Each component encapsulates a specific feature of a blog post, such as title, author, type, and description.&lt;/p&gt;</description></item><item><title>Function Component</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/001-function-component/</link><pubDate>Tue, 29 Jul 2025 07:41:04 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/02-module/001-function-component/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores how React function components use props to pass data, set default values, and handle events. It covers the principles of reusability, unidirectional data flow, customization, and composition, as well as practical event handling and conditional rendering techniques.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="working-with-function-components--props-and-event-handling"&gt;Working with Function Components – Props and Event Handling&lt;/h2&gt;
&lt;p&gt;Function components in React use properties, known as props, to pass data from parent to child components. Props are similar to objects and store the attributes of a component. They are immutable, meaning their values cannot be changed by the child component.&lt;/p&gt;</description></item></channel></rss>