<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>State-Management on Ghafoor's Personal Blog</title><link>http://ghafoorsblog.com/tags/state-management/</link><description>Recent content in State-Management 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><lastBuildDate>Sat, 16 May 2026 17:42:12 +0100</lastBuildDate><atom:link href="http://ghafoorsblog.com/tags/state-management/index.xml" rel="self" type="application/rss+xml"/><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>Passing Data Between Components</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/01-module/010-data-bw-component/</link><pubDate>Sat, 26 Jul 2025 19:20:24 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/05-frontend-react/01-module/010-data-bw-component/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores how React components manage and exchange data and state, detailing the component lifecycle phases, parent-child and child-parent communication patterns, and practical examples for robust state management in modern React applications.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="react-component-lifecycle-and-data-flow"&gt;React Component Lifecycle and Data Flow&lt;/h2&gt;
&lt;p&gt;React components have three main lifecycle phases: mounting, updating, and unmounting. Each phase involves specific methods that control how components are created, updated, and removed from the DOM.&lt;/p&gt;
&lt;h3 id="lifecycle-phases"&gt;Lifecycle Phases&lt;/h3&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Phase&lt;/th&gt;
 &lt;th&gt;Description&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;Mounting&lt;/td&gt;
 &lt;td&gt;Component is created and inserted into the DOM&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Updating&lt;/td&gt;
 &lt;td&gt;Component re-renders due to state or prop changes&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Unmounting&lt;/td&gt;
 &lt;td&gt;Component is removed from the DOM&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 id="mounting-methods"&gt;Mounting Methods&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;constructor&lt;/strong&gt;: Initializes the component and state, may call &lt;code&gt;super(props)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;getDerivedStateFromProps&lt;/strong&gt;: Syncs state with props if needed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;render&lt;/strong&gt;: Returns the JSX for the UI (must return a single root element).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;componentDidMount&lt;/strong&gt;: Runs after the component is mounted; often used for data fetching or subscriptions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="updating-methods"&gt;Updating Methods&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;getDerivedStateFromProps&lt;/strong&gt;: Called before every render if props change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;shouldComponentUpdate&lt;/strong&gt;: Determines if a re-render is needed (returns &lt;code&gt;true&lt;/code&gt; by default).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;render&lt;/strong&gt;: Updates the UI based on new state/props.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;getSnapshotBeforeUpdate&lt;/strong&gt;: Captures information from the DOM before changes are applied.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;componentDidUpdate&lt;/strong&gt;: Runs after updates are flushed to the DOM.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="unmounting-method"&gt;Unmounting Method&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;componentWillUnmount&lt;/strong&gt;: Used for cleanup (e.g., removing timers or listeners).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="passing-data-between-components"&gt;Passing Data Between Components&lt;/h2&gt;
&lt;p&gt;Data can be passed between React components in several ways, depending on their relationship.&lt;/p&gt;</description></item></channel></rss>