<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mona fakhri</title>
    <description>The latest articles on DEV Community by mona fakhri (@mona_fakhri_98b07b8a1fd66).</description>
    <link>https://dev.to/mona_fakhri_98b07b8a1fd66</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3505087%2F734873f1-c2b1-4970-b4a8-2eec9b4e8b81.jpg</url>
      <title>DEV Community: mona fakhri</title>
      <link>https://dev.to/mona_fakhri_98b07b8a1fd66</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mona_fakhri_98b07b8a1fd66"/>
    <language>en</language>
    <item>
      <title>Day 1 React</title>
      <dc:creator>mona fakhri</dc:creator>
      <pubDate>Sat, 27 Sep 2025 17:19:14 +0000</pubDate>
      <link>https://dev.to/mona_fakhri_98b07b8a1fd66/day-1-react-4j2l</link>
      <guid>https://dev.to/mona_fakhri_98b07b8a1fd66/day-1-react-4j2l</guid>
      <description>&lt;h2&gt;
  
  
  What is React?
&lt;/h2&gt;

&lt;p&gt;react is JavaScript library for building user interfaces &lt;br&gt;
developed at Facebook and released to the world in 2013&lt;/p&gt;
&lt;h2&gt;
  
  
  How does react work?
&lt;/h2&gt;

&lt;p&gt;react creates virtual DOM in memory&lt;br&gt;
instead of manipulating the browser's DOM directly, react creates a virtual DOM in memory, where it does all the necessary manipulating before making the changes in browser DOM&lt;br&gt;&lt;br&gt;
React only changes what needs to be changed!&lt;/p&gt;
&lt;h2&gt;
  
  
  why React?
&lt;/h2&gt;

&lt;p&gt;1.Easy creation of dynamic application &lt;br&gt;
2.reusable components&lt;br&gt;
3.dedicted tools for easy debugging &lt;/p&gt;
&lt;h2&gt;
  
  
  VIRTUAL DOM
&lt;/h2&gt;

&lt;p&gt;the virtual DOM is only a virtual representation of the DOM.&lt;/p&gt;



&lt;p&gt;When new elements are added to the &lt;br&gt;
UI, a virtual DOM, which is &lt;br&gt;
represented as a tree is created. &lt;br&gt;
● Each element is a node on this tree. &lt;br&gt;
If the state of any of these elements &lt;br&gt;
changes, a new virtual DOM tree is &lt;br&gt;
created. &lt;br&gt;
● This tree is then compared with the &lt;br&gt;
previous virtual DOM tree, the &lt;br&gt;
virtual DOM calculates the best &lt;br&gt;
possible method to make these changes &lt;br&gt;
to the real DOM. This ensures that &lt;br&gt;
there are minimal operations on the &lt;br&gt;
real DOM.&lt;/p&gt;
&lt;h2&gt;
  
  
  React APP Structure
&lt;/h2&gt;

&lt;p&gt;** JSX**&lt;br&gt;
JSX stands for JavaScript XML and allows us to write HTML in React.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coding JSX&lt;/strong&gt;&lt;br&gt;
JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() or appendChild() methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expressions in JSX&lt;/strong&gt;&lt;br&gt;
with JSX you can write expressions inside curly braces {}.&lt;br&gt;
the expression can be variable, property, or any other valid JavaScript expression. JSX will execute the expression and return the result. &lt;/p&gt;
&lt;h2&gt;
  
  
  React Components
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Components are independent and reusable bits of code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Components com in two types, class components and function components &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Components are like functions that return HTML elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Component represent the part of user interface, before React Hooks, when we want to create a dynamic component, we have to create a class component and use lifecycle methods to change states to make it reusable and encapsulate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is regular ES6 classes that extends component class form react &lt;br&gt;
library, also known as “stateful” components because they implement &lt;br&gt;
logic and state.It must have render() method returning html.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;● Functional component :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const App = ( ) =&amp;gt; {return (&amp;lt;h1&amp;gt; Hello &amp;lt;/h1&amp;gt;)};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;● Class component :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends Component{
 render( ){ 
return (&amp;lt;h1&amp;gt; Hello &amp;lt;/h1&amp;gt;)}
 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Component lifecycle
&lt;/h2&gt;

&lt;p&gt;there are 3 phases in React component :&lt;/p&gt;

&lt;p&gt;● Mounting&lt;br&gt;
 ● Updating&lt;br&gt;
 ● Unmounting&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mounting&lt;/strong&gt; &lt;br&gt;
 When mounting you have 4 lifecycle methods :&lt;br&gt;
1.Constructor&lt;br&gt;
the constructor is the first method that is called when mounting a component.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;render() 
from the render() method you return the JSX that builds the component interface.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;3.ComponentDidMount()&lt;br&gt;
this method is the one that you will use to perform API calls, or process operation on the DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updating&lt;/strong&gt;&lt;br&gt;
1.ComponentDidUpdate()&lt;br&gt;
this method is called when the component ha been updated in the DOM.&lt;/p&gt;

&lt;p&gt;** Unmounting**&lt;br&gt;
 ● componentWillUnmount()&lt;br&gt;
 The method is called when the component is removed from the DOM. Use this to do any sort of cleanup you need to &lt;br&gt;
perform.&lt;/p&gt;
&lt;h2&gt;
  
  
  Props and State
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Components need data to work with. There are two different ways that you 
can combine components and data: either as props or state.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Props
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;props is short for properties and they are used to pass data between react components. React data flow between components is uni-direction (from parent to child only)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;in a class component, props are passed by default. there is not add anything special , and they are accessible as this.props in a Component &lt;br&gt;
instance. &lt;br&gt;
_React props can be of any data type, including variables, numbers, strings, objects, arrays, and more.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Strings can be sent inside quotes as in the examples above, but numbers, variables, and objects need to be sent inside curly brackets._&lt;/p&gt;
&lt;h2&gt;
  
  
  State
&lt;/h2&gt;

&lt;p&gt;● special built-in object called state, which allows components to create and manage &lt;br&gt;
their own data. &lt;br&gt;
● In the Component constructor, initialize this.state&lt;br&gt;
 ● Can Update state using this.setState() method&lt;br&gt;
 ● Don’t mutate ( change ) state directly , always use setState( ) method to change &lt;br&gt;
state value that cause this component to rerender and update view&lt;/p&gt;
&lt;h2&gt;
  
  
  Handling Events
&lt;/h2&gt;

&lt;p&gt;Handling events with React &lt;br&gt;
elements is very similar to &lt;br&gt;
handling events on DOM &lt;br&gt;
elements.&lt;br&gt;
 Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;button onClick={addUsers}&amp;gt;
 Add Users
 &amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Comparison Table: Functional Components vs. Class Components
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fapj38u62pktm980o6wsj.png" alt=" " width="800" height="415"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Single page application
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9h3m9tz0bwxdkupg74yq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9h3m9tz0bwxdkupg74yq.png" alt=" " width="722" height="348"&gt;&lt;/a&gt;&lt;br&gt;
`&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>react</category>
    </item>
  </channel>
</rss>
