<?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 Patience Adajah on Medium]]></title>
        <description><![CDATA[Stories by Patience Adajah on Medium]]></description>
        <link>https://medium.com/@patienceadajah?source=rss-4836c83f00e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9MvllQfkkExyy1qy.jpg</url>
            <title>Stories by Patience Adajah on Medium</title>
            <link>https://medium.com/@patienceadajah?source=rss-4836c83f00e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 23:36:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patienceadajah/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[Why was Bitcoin invented?]]></title>
            <link>https://blog.blockmagnates.com/why-was-bitcoin-invented-a751aaaaf012?source=rss-4836c83f00e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a751aaaaf012</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Patience Adajah]]></dc:creator>
            <pubDate>Sun, 03 Apr 2022 16:05:09 GMT</pubDate>
            <atom:updated>2022-07-20T13:29:01.719Z</atom:updated>
            <content:encoded><![CDATA[<p>We cannot talk about the invention of cryptocurrencies or bitcoin without tracing our steps back and looking at the history of money itself.</p><p>Currency is a medium of exchange for goods and services, which is generally acceptable by a large group of people at a specific time.</p><p><strong>A brief history of money</strong></p><p>Money is an important social tool in human interactions. The history of money is dated as far back as the history of man. Over the years, man has learned to exchange and communicate value through a medium, which we call money. Money has evolved over the years, centuries and millennials. At different points in human history, we have had trade by barter, then we exchange value through precious substances such as precious stone, gold, salt, and then fiat. As money evolved, money became backed and issued by the government.</p><p>Initially, with trade by barter, people could exchange one good they had for another good they did not have which is usually something they could consume. Afterwards, this changed and people started using substances which were not consumable but had intrinsic value as money such as feathers, beads, cowries, shells, gold and silver. This happened for thousands of years.</p><p>Interestingly, people thought instead of carrying gold and precious stones around, they could deposit their gold with someone trustworthy and get issued a paper which represents the deposited gold and then they can trade with that paper instead of carrying the gold around. This gave birth to a whole finance industry. This is how it works with our current financial institutions.</p><p>The financial institutions act as a third trusted party between people and allow them to transact freely because we both trust the financial institutions to do a good job of keeping record of our financial transactions. After paper money, which was in use for years, we saw the advent of cashless economies with the issuance of plastic cards by a bank(trusted intermediary) which just represents money in the bank and with the card we don’t have to go around with bundle of currency notes, we just use our cards to represent what we have in our bank accounts and the financial institutions keep the records of how money is spent and received. Financial institutions do a good job of making sure that you do not spend money twice as every record is kept (double spending).</p><p><strong>Enter Cryptocurrencies</strong></p><p>As money evolved, technology also evolved, thanks to the works of early fathers of computing such as Charles Babbage, Alan Turing and the rest of them.</p><p>Cryptocurrencies are not an entirely new concept, they started as far back as the 1980s. Over the years there have been several attempts to create a digital form of currency which proved to be unsuccessful.</p><p>Innovators thought that what if we could actually perform financial transactions electronically without the centralized intermediary(i.e. Banks)?</p><p>In 1995, An American cryptographer David Chaum attempted to make this possible by implementing a cryptographic electronic money called DigiCash. DigiCash allowed computer software to withdraw from a bank and required some specific encryption keys before the funds could be transferred to a recipient. In 1998, Nick Szabo designed BitGold, which is usually referred to as the direct precursor to bitcoin. It required a participant to dedicate computer resources to solving cryptographic puzzles and whoever solved the puzzle successfully received the reward. With both DigiCash and BitGold, there was a problem which is referred to as the double spending problem.</p><p>Double spending is a problem that arises when transacting cryptocurrencies that involves the same unit of cryptocurrency being spent twice or multiple times. Double spending is possible because cryptocurrencies can be easily reproduced. With a double spend attack, a fraudulent actor can reverse a crypto transaction and then double spend a coin.</p><p>In order to solve this double spending problem, a very strict verification process has to be put in place to ensure that the same input cannot be shared over multiple transactions. This can either be done by a centralized third party verifying the authenticity of a transaction or by a decentralized means.</p><p>Already, we have established that the whole idea of cryptocurrencies is to eliminate the centralized entities(i.e banks), so that is not an option to combat the double spend problem.</p><p><strong>Enter blockchain</strong></p><p>In 2008, a mysterious person or persons, with the name Satoshi Nakamoto published the whitepaper called Bitcoin — A peer-to-peer Electronic cash system describing the functionality of the bitcoin blockchain network. Bitcoin was the first cryptocurrency that was able to solve the double spend problem.</p><p><strong>How does bitcoin solve this problem?</strong></p><p>Bitcoin solves this problem by using a consensus mechanism. It means instead of having a central and trusted third party verify the authenticity of a transaction, a decentralized approach is used. Bitcoin is using blockchain technology and a blockchain is basically just blocks of data. These blocks of data are stored in nodes(think of nodes as small servers). A node can be any device but usually, it is a computer or a laptop. Nodes form the infrastructure of a blockchain. All nodes are connected to each other and they keep a record of the latest blockchain data, so each node stays up to date. The consensus mechanism ensures that each node verifies the transaction. So authenticity is given to the first transaction that is received by each of the servers. So in a case where a transaction is duplicated or the same token is used for payment, the duplicated transaction will be deemed invalid as the server will only validate the first transaction. Once a transaction has been recorded in the network it is nearly impossible for it to be changed. Since the blockchain is not stored on a single device but spread across a network of several computers, it is resilient and makes it difficult for a corrupt actor to wipe out data already stored on the blockchain.</p><p>Bitcoin, since 2008 has gained mainstream adoption across a wide group of people who believe in the innovation it provides to finance as we once knew it. It is the first cryptocurrency with such widespread adoption.</p><p>The consensus mechanism is a very powerful mechanism and the only way a corrupt actor can double spend with this mechanism is when there is a 51% attack. I will talk about this in the next article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a751aaaaf012" width="1" height="1" alt=""><hr><p><a href="https://blog.blockmagnates.com/why-was-bitcoin-invented-a751aaaaf012">Why was Bitcoin invented?</a> was originally published in <a href="https://blog.blockmagnates.com/">Block Magnates</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is web 3.0 and why should you care?]]></title>
            <link>https://medium.com/@patienceadajah/what-is-web-3-0-and-why-should-you-care-cd768029195c?source=rss-4836c83f00e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd768029195c</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Patience Adajah]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 10:47:09 GMT</pubDate>
            <atom:updated>2022-03-15T10:47:09.489Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="An image of with blockchain illustration and web 3.0 text" src="https://cdn-images-1.medium.com/max/550/1*7R_jhYlTFjB-Ob8yxas-pQ.jpeg" /></figure><p>If you are a frequent Twitter user, by now you are probably tired of seeing the word “web 3” countless times as you scroll through your feed. Web 3.0 has become a buzzword in recent times.</p><p>How has web 3.0 changed the web as we know it or how is it going to change our activities on the web?</p><p>Before we delve into web 3.0, let’s take a brief look at how we got here. What was the web like before web 3.0?</p><p><strong>Web 1.0</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*pkSOXHTyLLCBewSxHDUbUg.png" /></figure><p>The web was invented in 1989 by a British scientist named Tim Berners-Lee. These were the early days of the web. Also referred to as web 1.0. This era of the web lasted until 2005. Web 1.0 was mostly just static web pages. It was mostly business pages and directories. Most of the web pages were read-only, just designed for information consumption with little interactivity by users.</p><p><strong>Web 2.0</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*5TrFoUYgLNjCUerIpoCvOQ.png" /></figure><p>Web 2.0 is the second stage of the web. It is also referred to as the “read-write” web. This stage of the web witnessed the massive progression from just static web pages to highly interactive web apps where users have the power to not only read but also write to the web. This era birthed a phase where applications have user-generated content, giving power to the users to become creators.</p><p>The growth of web 2.0 was highly facilitated by mobile internet access and social networks. Social networks brought about a wide range of web applications such as Facebook(now meta), Instagram, Youtube, TikTok, and several others. With the ubiquitous nature of our smartphone devices, it means we can stay connected and access the web all day long. Businesses in every sector have had to adapt to these innovations and bring their businesses online.</p><p>Web 2.0 brought about the gig economy, with the connectivity it provides people could connect with people from all over the world and offer their skills. Businesses also could scale outside their geographical locations.</p><p>In Web 2.0, data is centralized and is dominated by some big tech companies such as Google and Amazon. These big tech companies own a huge chunk of resources responsible for internet connections. The consolidation of power among these small groups of big tech companies has brought about some challenges that have incited the need for a decentralized internet connection.</p><p><strong>Web 3.0</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtzpB1lxNTfxbrBKAFhpWw.png" /></figure><p>Web 3.0 is the third phase in the evolution of the web. Web 3.0 aims to solve some of the challenges with web 2.0. Web 3.0 is referred to as the semantic web, which is a word coined by Tim Barnes Lee, the original inventor of the web. In web 3.0, we are going to witness an even more disruption of the web as we know it. Web 3.0 is built on important core values which include decentralization, openness, permissionless, and trustless.</p><p>With decentralization, data will no longer be stored in massive databases held by internet giants. Instead, data will be stored in multiple locations simultaneously, eliminating the need for third-party middlemen. Here users do not only read and write but also own the platform.</p><p>Most of the web 3.0 applications are open which means they are built on open-source software and accessible to people from all over the world with an internet connection.</p><p>Permissionless and trustless simply means users can participate without authorization from a governing body and interact publicly without a third-party intermediary.</p><p>Use cases of web 3.0</p><ul><li>Cryptocurrencies &amp; NFTs</li></ul><p>Cryptocurrencies are digital currencies built on blockchain technology that is secured by cryptography. An important aspect of cryptocurrencies is that they are not issued by any governmental authorities. With an internet connection, anyone can participate in a peer-to-peer cryptocurrency network making it easier to make cross-border transactions. Cryptocurrencies like bitcoin, ethers, and many others are redefining how value is stored and exchanged.</p><p>Web 3.0 has also paved the way for artists and creators to own the platforms they use through NFTs. Creators can put their creative works on the blockchain(mint) and blockchain keep a record of ownership from one account to the next.</p><ul><li>Decentralized Finance</li></ul><p>Web 3.0 brought about the rise of DeFi. DeFi platforms and protocols offer financial instruments such as lending and borrowing without a third party such as traditional financial institutions. These financial activities are facilitated by smart contracts on a blockchain.</p><ul><li>Decentralized Governance structure</li></ul><p>Web 3.0 has brought about the rise of Decentralized Autonomous Organizations(DAOs). DAOs are communities governed by rules which are encoded on a smart contract to establish and execute agreed decisions by the community members. A popular example is the <a href="https://www.forbes.com/sites/abrambrown/2021/12/01/crypto-tokens-people-constitution-dao-ether-redeem-refund/?sh=39eeca6a6f3f">constitution DAO</a>, a group of people formed a DAO to buy the US constitution.</p><p>Web 3.0 is still very much in its early phase. A lot of experimentation is still being done and in the next couple of years, we would see more innovations in this space, and even more use cases will arise to make the web more private, controlled, and owned by its users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd768029195c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to send emails from a React application without a backend(server).]]></title>
            <link>https://medium.com/@patienceadajah/how-to-send-emails-from-a-react-application-without-a-backend-server-1dd8718ceedd?source=rss-4836c83f00e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dd8718ceedd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Patience Adajah]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 21:31:16 GMT</pubDate>
            <atom:updated>2020-09-09T21:31:16.073Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometime ago, I was working on a static website with React, everything went pretty well until I ran into a problem. On the contact page of my application, I had a contact form to allow users send messages to the admin. The problem was, my application was entirely a front-end application and I had no server because I didn’t need one. Sending emails entirely from the front-end was my challenge.</p><p>After a bit of google search, I found out about EmailJS. Just exactly what I needed.</p><p>In this article, I would be explaining the process that solved my problem, so you can also implement it in your project if you run into the same problem.</p><ol><li>Create an account on <a href="https://www.emailjs.com/">EmailJS</a>.</li><li>On your dashboard, Click on Email Services and Choose your preferred email service provider, I chose Gmail for mine.</li><li>Still on your dashboard, Click on Email template an Create an email template for your email. This will determine the format in which you(the receiver) will receive the email. You could also create a template for auto-response to automatically send an email back to the sender(this is optional though). Also, set an email, where the emails will be sent.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRfGD7Zpo7TF-5r7RoGj7w.png" /><figcaption>An example template made in emailJS</figcaption></figure><pre>//an example template</pre><pre>From: {{{firstname}}} + {{{lastname}}}<br>Email: {{{email}}}<br>Phone: {{{phone}}}<br>Message: {{{message}}}</pre><p>4. Create a file in your application (say emailkey.js). In that application, you will keep your secret keys from EmailJs. To get your User_ID and Access token, click on Integration.</p><p>NB: A more secure way to handle this is keeping your keys in a .env file and adding the file to your .gitignore to prevent it from being committed to github. Read more about that <a href="https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa">here</a>.</p><p>Also, to add an extra layer of security, to avoid unauthorized request with your key, be sure to restrict your domains, by clicking on settings on your dashboard and specifying the domain.</p><p>In your emailkey.js file you have the following code snippet</p><pre>export default {<br>USER_ID: `user_twJMhT1XLr7XXXXXXXXXX`, //userID</pre><pre>TEMPLATE_ID: `hexpower_temp`,         //templateID</pre><pre>}</pre><p>5. In your component, where you have the contact form, add the following code to your onSubmit function. Ensure the name attribute used in your input fields matches what you used in the template in EmailJS.</p><pre>const handleSubmit = (e) =&gt; {</pre><pre>e.preventDefault(); // Prevents default refresh by the browser</pre><pre>emailjs.sendForm(`gmail`, apiKey.TEMPLATE_ID, e.target, apiKey.USER_ID)</pre><pre>.then((result) =&gt; {</pre><pre>alert(&quot;Message Sent, We will get back to you shortly&quot;, result.text);</pre><pre>},</pre><pre>(error) =&gt; {</pre><pre>alert(&quot;An error occurred, Please try again&quot;, error.text);</pre><pre>});<br>};</pre><p><strong>Conclusion</strong></p><p>That’s all the steps it takes. With this, you can send emails directly from your front end application.</p><p>Thanks for reading and I hope it helps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dd8718ceedd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mimicking Lifecycle methods with Hooks in React]]></title>
            <link>https://medium.com/swlh/mimicking-lifecycle-methods-with-hooks-in-react-6c5cb475a2f0?source=rss-4836c83f00e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c5cb475a2f0</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-lifecycle]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Patience Adajah]]></dc:creator>
            <pubDate>Sat, 27 Jun 2020 11:08:19 GMT</pubDate>
            <atom:updated>2020-06-30T03:07:19.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUnxGuEY1IgDDcZXVFwSZw.png" /></figure><p>Starting out with React, I jumped in on writing functional components, I had some troubles using the useEffect hook, as I didn’t fully understand the component lifecycles.</p><p>I did a bit of biology and I enjoyed studying a lot about the lifecycles, especially the lifecycles of insects. How they progress from one stage to another until they finally become adults.</p><p>Just as it is in biology, I quickly realized that components in react also pass through a lifecycle. Components pass through different stages in their lifetime and possibly die at some point.</p><p>React components pass through three lifecycles: Mounting, Updating and Unmounting.</p><ul><li><strong>Mounting:</strong> here, it is simply putting elements in the DOM. At this stage, react has built in methods which are:</li></ul><ol><li>constructor()</li><li>getDerivedStateFromProps()</li><li>render()</li><li>componentDidMount()</li></ol><p>At this stage, the render method will always be called in class components. The other methods will be called if you define them.</p><ul><li><strong>Updating:</strong> A component is updated, whenever there is a change in the component. This could be either via props or state. The react built in method for updated components are:</li></ul><ol><li>getDerivedStateFromProps()</li><li>shouldComponentUpdate()</li><li>render()</li><li>getSnapshotBeforeUpdate()</li><li>componentDidUpdate()</li></ol><ul><li><strong>Unmounting:</strong> A component is unmounted when it is removed from the DOM. There is just one built in method here, which is componentWillUnmount.</li></ul><p>These component lifecycles are only available when writing class components. With functional components, some of these lifecycle methods are mimicked with react hooks. Mostly useState() and useEffect() hook.</p><p><strong>constructor =&gt; useState()</strong></p><p>Normally, in the constructor method, you set the initial values for state and bind the keyword “this” to refer to the current object in non-lifecycle methods. The constructor runs before the component is rendered.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fc4401b7f6655bcb3f3362f562988d8/href">https://medium.com/media/2fc4401b7f6655bcb3f3362f562988d8/href</a></iframe><p>In the above example, the Greeting component has three methods that run in the following order:</p><ul><li>constructor() — sets the initial “greeting” state and binds the reference to “this” in the context of the setGreeting method.</li><li>render() — determines what content is displayed or “returned” by this component; initially only renders a button (with an event listener) and an empty paragraph (based on the empty string set for this.state.greeting in the constructor).</li></ul><p>If a user clicks the button:</p><ul><li>setGreeting() — updates the greeting state from an empty string to ‘Hello World!’, causing the component to re-render and triggering cliche alarms everywhere.</li><li>render() — runs again, now displaying “Hello World!” in place of the previous empty string.</li></ul><p>Now to build the same component with functional components, we get this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a3a34046429295dcbe8e47796dde1b1/href">https://medium.com/media/4a3a34046429295dcbe8e47796dde1b1/href</a></iframe><p>With “useState()”, it’s possible to simultaneously set an initial value for “greeting” and create the “setGreeting” function for updating the state in the future.</p><p><strong>componentDidMount, componentDidUpdate and componentWillUnmount =&gt; useEffect()</strong></p><p>Think of useEffect Hook as componentDidMount, componentDidUpdate, and componentWillUnmount combined. This method is triggered automatically after a component is successfully mounted and rendered for the first time. It is also useful when fetching data from an API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf7778402775b6163e94974adeb56770/href">https://medium.com/media/bf7778402775b6163e94974adeb56770/href</a></iframe><p>The code above follows this pattern:</p><ul><li>constructor/render — mounts and renders the component in an incomplete state (often with some sort of loading indicator)</li><li>componentDidMount — fetches data from an imaginary API and uses that data to update the component’s state, triggering the component to re-render</li><li>render — the component renders again, this time using the data fetched in componentDidMount to fully serve its intended purpose.</li></ul><p>With useEffect() in functional components, the above code snippet is becomes:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9b59cc691a2ebf5aa486c09a5090e66/href">https://medium.com/media/a9b59cc691a2ebf5aa486c09a5090e66/href</a></iframe><p>Finally, I hope this helped you to understand how you can mimic lifecycle methods from class components in functional components with react hooks.</p><p><strong>Resources</strong></p><p><a href="https://medium.com/swlh/react-lifecycle-hooks-71547ef4e7a8">https://medium.com/swlh/react-lifecycle-hooks-71547ef4e7a8</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c5cb475a2f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/mimicking-lifecycle-methods-with-hooks-in-react-6c5cb475a2f0">Mimicking Lifecycle methods with Hooks in React</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with React: The building blocks]]></title>
            <link>https://medium.com/@patienceadajah/getting-started-with-react-the-building-blocks-ba166518cf6e?source=rss-4836c83f00e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba166518cf6e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Patience Adajah]]></dc:creator>
            <pubDate>Mon, 08 Jun 2020 01:45:19 GMT</pubDate>
            <atom:updated>2020-06-08T01:45:19.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CeuWv9fCjD1uTiTuKytnBQ.png" /></figure><p>When I started out with JavaScript, I built some beginner projects with vanilla JavaScript, when it was time to work on a real life project, I had to work with React, which is a JavaScript library . With React, I didn’t have to write from scratch when developing the product.</p><p>In the JavaScript ecosystem, there are quite a number of frameworks/libraries for building user interfaces(UIs). React is the most commonly used library, others include Vue and Angular.</p><p><strong>So what is React?</strong></p><p>React is a component based web development library for making user interfaces and offering declarative views, which makes the code more predictable and easier to debug. React was developed and is also currently maintained by Facebook.</p><p><strong>What makes React popular among software developers?</strong></p><ul><li>React works with the <a href="https://reactjs.org/docs/faq-internals.html">virtual <strong>Document Object Model(DOM)</strong></a>. This is a key feature that enables React to build scalable and fast applications both in the web and on mobile.</li><li>React library is based on components. Components allow you reuse your code in React at any level without changes in them.</li><li>React follows one-way data binding or unidirectional data flow that gives better control throughout the application. This simply means data goes one way in React. when designing a React app, child components are nested within higher order parent components. Data is passed down from parent components to their children. Think about how you inherited some characteristics from your parents. Similarly, Parent components pass down properties to child components.</li></ul><p><strong>Basics you must know before learning React(Prerequisite).</strong></p><ul><li>Knowledge of Hypertext Markup Language(HTML) and Cascading Style Sheet(CSS).</li><li>Understanding of modern JavaScript.</li><li>A basic understanding of how the Document Object Model (DOM) works.</li><li><a href="https://nodejs.org/en/download/">Node.js</a> and npm installed globally.</li></ul><p><strong>React Setup and installation</strong></p><p>There are two ways to set up React for your project.</p><ol><li><strong>Static HTML file(Not advisable)</strong></li></ol><p>This is not a popular method to set up React but it works nonetheless.</p><ul><li>Create an HTML file named index.html</li><li>Start by including these <a href="https://reactjs.org/docs/add-react-to-a-website.html">three scripts</a> in your HTML head tag.</li></ul><p>The first two scripts allow you to write React code in JavaScript and the third, Babel allows you to write <strong>JavaScript XML(JSX)</strong> syntax(you will learn more on JSX going forward).</p><p>This method of setting up react is not very efficient and it is hard to maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E5in3inmExe6N9WK" /></figure><p><strong>2. Set up React Environment</strong></p><p>You can set up a React environment with <strong>create-react-app</strong>, which comes with boilerplate code with everything set up to build your project. It creates a live development server at <strong>localhost:3000</strong> where <strong>3000</strong> is the port number, it uses webpack to automatically compile React, ES6 and JSX.</p><p>To set up <strong>create-react-app</strong>, ensure you have <a href="https://nodejs.org/en/download"><strong>Node</strong></a> and <strong>npm</strong> installed on your computer. Note that <strong>npm </strong>is install automatically when you install Node</p><p>You can install <strong>create-react-app</strong> by running the following command in your terminal.</p><pre>npx create-react-app my-app</pre><p>The “my-app” represents the name of your project. You can call it anything you want.</p><p>The create-react-app will set up your react environment with everything you need. When it is completed, run the react application with the following commands.</p><pre>cd my-app<br>npm start</pre><p>A new browser window will pop up with your newly created React app hosted on localhost:3000. If it does not, go to your browser and type localhost:3000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2dV-EUPd-koH4odI" /></figure><p>Your react app will run on that portal, just as seen above.</p><p><strong>The react environment from your create-react-app includes these files/folder</strong></p><ul><li>node_modules — contains all the node dependencies.</li><li>public — public files that are served.</li><li>src — source code of your react app.</li><li>gitignore — records which files git should ignore.</li><li>package.json — contains various metadata relevant to the project.</li><li>package-lock.json — contains an exact version dependency tree.</li></ul><p><strong>Modify the React Application</strong></p><p>Remove unnecessary imports from the app.js in the src folder. Change the HTML content and save the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lo0DvbVSysShifhg" /></figure><p>You will see the text “My react app” displayed in your browser.</p><p><strong>JSX: Javascript + XML</strong></p><p>In React, we write HTML looking code which is not quite HTML but JSX, which stands for Javascript XML.</p><p>Example of JSX</p><pre>let heading = &lt;h1 className=”my-heading”&gt;I am the heading&lt;/h1&gt;</pre><p>Things to note with JSX.</p><ul><li>className is used instead of class for adding css classes as class is a reserved keyword in JavaScript.</li><li>Properties and methods are written in camelCase.</li></ul><p>Onclick becomes onClick</p><ul><li>Self-closing tag must end in a slash. Ex. &lt;img /&gt;</li><li>Javascript expressions can be embedded in JSX using curly braces, including variables, functions and properties.</li></ul><pre>Const name = “Patience”</pre><pre>Const greeting = &lt;p&gt; Hello, {name} &lt;/p&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*znicrg4ZQJt31xOv" /></figure><p>This is what is displayed in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i4dFhVKNEyJfrx_P" /></figure><p><strong>Components</strong></p><p>Components are the backbones of react, which can be class components or functional components.</p><p>Most React apps have many small components and which leads to the main app.js file. In recent times, functional components have become very popular, hence, we will be writing our components as functional components. Before then, let’s create a simple component as a class component and as a functional component.</p><p>Here is a simple class component,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XWfEQxbmdeDLEZEJ" /></figure><p>Here is a functional component</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nADsTifCTbAWfvUa" /></figure><p>A functional component is just a plain javaScript function and with functional components, you write less code and your code looks cleaner.</p><p><strong>Props (short for Properties)</strong></p><p>One of the big deals about React is how it handles data, one of the ways is by passing props.</p><p>Props are an effective way of passing existing data to a React component. Props can be passed down from parent components to child components. In the component I created earlier, instead of hardcoding my name, I will pass props(in this case, name) from the parent component(app.js) to the child component(welcome.js).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cm_PN6h6ptMaFMgG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vzPrcN_8LvLMvwcf" /></figure><p>Since components are reusable, you can reuse the welcome.js component and pass different props to each of the components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fAB4oSTSqi6jDiTQ" /></figure><p>The component cannot change the props — they are read only. To have further control over handling data in React, state is used.</p><p><strong>State</strong></p><p>State is basically for storing data. With state, data can be modified and updated unlike props. With state an initial value is set for the state and the value can be updated with setState(). With class components, you create a state object to store your state but with functional components, which is just a plain JavaScript function, you cannot do that. So you use the useState hook instead.</p><p>This brings us to talking about hooks in React. Hooks in React is a broad topic and it is not the main focus of this article, so I will just give an overview of what hooks are as we will be using the useState hook.</p><p>Hooks do not work with class components but they are an awesome feature of functional components. Hooks are functions that let you “hook into” React state and lifecycle features from function components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JC2ktkqIVvAzByqK" /></figure><p>Here in this component, I imported the useState hook form react, then created a state to store a name, the state is updated as the button is clicked.. In this case, the setName() is updating the state.</p><p>Apart from the useState hook, other hooks include useEffect, useReducer, useRef, useCallback, useMemo. You can also go on to write your own custom hooks.</p><p><strong>Conclusion</strong></p><p>This article is to give you the basics of React and how react works. React is broad and there is so much more to learn and do with React. Notwithstanding, by now, you should have a good grasp of React and be confident enough to start getting your hands dirty by building your first project with React.</p><p><strong>Resource</strong></p><ul><li><a href="https://reactjs.org/docs/getting-started.html"><strong>https://reactjs.org/docs/getting-started.html</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba166518cf6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>