<?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 Onyebuchi Prince on Medium]]></title>
        <description><![CDATA[Stories by Onyebuchi Prince on Medium]]></description>
        <link>https://medium.com/@majornwa189?source=rss-4e6eccc25492------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O9kxyD-CGYhmW__kwhL4wA.jpeg</url>
            <title>Stories by Onyebuchi Prince on Medium</title>
            <link>https://medium.com/@majornwa189?source=rss-4e6eccc25492------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:37:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@majornwa189/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[Understanding Functional Components in React.]]></title>
            <link>https://medium.com/@majornwa189/understanding-functional-components-in-react-d44a0983740?source=rss-4e6eccc25492------2</link>
            <guid isPermaLink="false">https://medium.com/p/d44a0983740</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Onyebuchi Prince]]></dc:creator>
            <pubDate>Sun, 04 Oct 2020 10:07:03 GMT</pubDate>
            <atom:updated>2020-10-04T10:07:03.328Z</atom:updated>
            <content:encoded><![CDATA[<p>I have been learning React for some time now and coming across Functional components and how it makes your code easier to test and achieving better performance. I will share my understanding about it. I expect you to have the basic knowledge of React, although knowing ES6 will be helpful too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*F8YwshGPRIBK9mMYp3N5qA.jpeg" /></figure><h4><strong>What are Functional Components?</strong></h4><p>Before we answer that i will like to quickly explain what Components are in React according to the <a href="https://reactjs.org/docs/components-and-props.html">documentation</a>.</p><p>A Component helps you write independent codes which can be split into reusable pieces, so a component can be defined as classes or function.</p><p>Now back to <strong>Functional</strong> <strong>Components</strong>. There are two main types of components in React. <strong>Functional Components</strong> and <strong>Class Components. </strong>Class Components are ES6 classes while Functional Components are functions, pretty clear right.The only difference or limit is that functional component accept <strong><em>props </em></strong>as arguments to return valid JSX.</p><p>Take a look at this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*XcMWjE-pVn2pxlCS6yn6-A.png" /></figure><p>This is a simple way to define a component in React and this is a function and a Functional Component actually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9L5NQR4YWg6KQzCiPKL0Hg.png" /></figure><p>Above, we will get the same output and that is just ES6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UL11bk-UAmF84tGy18Btyg.png" /></figure><p>And also the exact same component but written as a Class Component.</p><p>Using either Functional component or Class component will give you the same output but if you are writing a presentational component which doesn’t have its own state or needs to access a lifecycle hook then you should use a Functional component.Class Components and Functional Components have some differences considering <strong>Syntax, State </strong>and <strong>Lifecycle Hooks.</strong>But you should go for Functional components because of these reasons:</p><ol><li>Being a fan of writing clean and less code, Functional components is the deal.</li><li>Functional Components are easy to test because you don’t have to worry about hidden state or <a href="https://en.wikipedia.org/wiki/Side_effect_(computer_science)">side effects</a>. For every props, functional components have exactly one output.</li><li>The performance benefits are interesting, decreased coupling and greater usability.</li><li>And for better debugging there is no need to continuously log the state of the component to understand what is going on.If you know the props being passed in, it’s easy to trace the path of your code and figure out what is taking place.</li></ol><h3>Conclusion</h3><p>Whether you are using Functional or Class components, the results can still be the same but there are some things that needs to be considered so as to make our life easier which we have discussed and it seems pretty clear the upsides outweigh the negatives because companies on the cutting edge of React development like Facebook, Netflix, and Airbnb all readily use functional components.So why not use it or at least try it out.Otherwise stick to class components if it makes your life easier also.😁</p><p>Please if this article is helpful to you or you enjoyed it, share the love by sending it to others too.Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d44a0983740" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>