<?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: kizadek</title>
    <description>The latest articles on DEV Community by kizadek (@kizadekmupela).</description>
    <link>https://dev.to/kizadekmupela</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%2F632624%2Fcacb1a62-9f42-4366-99fd-4c77c913e084.png</url>
      <title>DEV Community: kizadek</title>
      <link>https://dev.to/kizadekmupela</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kizadekmupela"/>
    <language>en</language>
    <item>
      <title>Props Vs State</title>
      <dc:creator>kizadek</dc:creator>
      <pubDate>Mon, 14 Feb 2022 09:03:34 +0000</pubDate>
      <link>https://dev.to/kizadekmupela/props-vs-state-25fc</link>
      <guid>https://dev.to/kizadekmupela/props-vs-state-25fc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SXiMFvIx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6te0k4xh1k7au3hff8h.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SXiMFvIx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6te0k4xh1k7au3hff8h.gif" alt="Image description" width="480" height="270"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;PROPS VS STATE&lt;/strong&gt;&lt;br&gt;
Props :: are used to pass data from one component to another and &lt;br&gt;
State :: is a local data storage that is local to the component only and cannot be passed to another components&lt;br&gt;
(i.e)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PROPS&lt;/strong&gt; &lt;br&gt;
(short for "properties") are read only. arbitrary inputs of a react component accepted as first argument to react component.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;React is a component-based library&lt;br&gt;
which divides the UI into little reusable pieces. In some cases known as component's, those components need to communicate (send data to each other) and the way to pass data between components is by using props.&lt;br&gt;
for example &lt;br&gt;
when u want to pass or (send) some data to a child component from the parent component then your child component access that data as props &lt;br&gt;
the data can be anything from&lt;br&gt;&lt;br&gt;
functions,variables,strings,arrys.....&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;But the important part here is that data with props is passed in a uni-directional flow. (one way from parent to child)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Furthermore, props data is read-only, which means that data coming from the parent should not be changed by child components.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class ParentComponent extends Component {     
    render() {     
        return (         
            &amp;lt;ChildComponent name="First Child" /&amp;gt;     
        );   
    } 
} 

const ChildComponent = (props) =&amp;gt; {     
    return &amp;lt;p&amp;gt;{props.name}&amp;lt;/p&amp;gt;;  
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Firstly, we need to define/get some data from the parent component and assign it to a child component’s “prop” attribute.&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;ChildComponent name="First Child" /&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;“Name” is a defined prop here and contains text data. Then we can pass data with props like we’re giving an argument to a function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ChildComponent = (props) =&amp;gt; {   
  // statements 
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, we use dot notation to access the prop data and render it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return &amp;lt;p&amp;gt;{props.name}&amp;lt;/p&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;some points to take note&lt;/p&gt;

&lt;p&gt;-Props are input value to components.&lt;br&gt;
-Props are data passed down from a parent component to a child component. A child component can never send a prop back to the parent component.&lt;br&gt;
-Props are read-only components that must be kept pure in other words, Props are immutable.&lt;br&gt;
-It passes custom data to your component and trigger state changes.&lt;br&gt;
-Props are the best way to pass data from one to another component.&lt;/p&gt;

&lt;p&gt;Props are nothing but properties used as arbitrary input in react. They are like all the arbitrary inputs you declare in one component but want to use it in other components. For example you declare a function in component A but want to use in component B and C, you store the function as props and call it inside other components by referring to that. Otherwise you can directly declare the function you want to use in the second component and use it inside that component&lt;/p&gt;

&lt;p&gt;I hope you find this helpful!&lt;br&gt;
the next part will finish with start  happy coding &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_EYNJznV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bijpjbdn61g1v9w7r05e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_EYNJznV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bijpjbdn61g1v9w7r05e.png" alt="Image description" width="880" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

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