<?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 Noureldean Swearky on Medium]]></title>
        <description><![CDATA[Stories by Noureldean Swearky on Medium]]></description>
        <link>https://medium.com/@noureldean.saed?source=rss-30126c2c821f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VMZLe4kLRNvWqut8.</url>
            <title>Stories by Noureldean Swearky on Medium</title>
            <link>https://medium.com/@noureldean.saed?source=rss-30126c2c821f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 08:53:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@noureldean.saed/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[So, you want to be a ReactJS developer?]]></title>
            <link>https://medium.com/@noureldean.saed/so-you-want-to-be-a-reactjs-developer-d14cfc2eb910?source=rss-30126c2c821f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d14cfc2eb910</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Noureldean Swearky]]></dc:creator>
            <pubDate>Tue, 07 Jun 2022 09:24:46 GMT</pubDate>
            <atom:updated>2022-06-07T09:24:46.430Z</atom:updated>
            <content:encoded><![CDATA[<h3>Preface</h3><p>Here, at <strong>Dash Technologies</strong>, we provide various tech services, part of these services is Front-End Web Development using ReactJS, and almost by definition, we’re interested in expanding our community in that domain, and leaving our prints on that community, we hope that you find use of our expertise, and wish to have you on board with us soon!</p><h3>Intro</h3><p>This article is aimed to guide you through your journey, best practices, and things to avoid doing during your time learning React development.</p><p>Other crucial skills for software development, like algorithms and data structures are not covered in this course, you may check websites that provide coding challenges for that goal, one great example is <a href="https://leetcode.com/">LeetCode</a>,</p><p>I will not claim objectivity while writing this article, all the steps, dos and don’ts came from my own personal experience through my humble 4 years as a React Front-end Developer, in addition to some which I learnt from my colleagues. At the end of the day, your own experience and practices is going to be your primary teacher.</p><p><em>This article assumes knowledge in the basics of software programming.This article is written to cover the latest version of React (17.0.2) at the time of writing, additions or deprecation may occur between the time of writing the article and the time of you reading it, please keep yourself up to date</em></p><h3>Let’s start‽ Not so fast…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/0*L-kUp6pncMO07yMV.png" /></figure><p>In any field, there will be a learning curve, that will start off low, you won’t learn much as you don’t understand very well how do things work together, you may know what will be the output of some code, but not how did your input get processed nor how the output was generated. But as you start understanding how components interact with one another, you’ll find yourself rapidly learning much in such a short period of time, and once you’ve reached decent proficiency in your field, you’ll find less and less things to learn about, and see yourself knowing how things are working, and now caring for how efficiently and scalably things bind together.</p><h3>Level 1 (The basics)</h3><p><em>A very brief introduction to HTML, CSS, and Javascript, for more, check the links</em> The most basic “Hello world” in a website requires knowledge in HTML (Hyper Text Markup Language), a markup language is a text processing language to annotate or distinguish certain parts of the document, much like <a href="https://www.markdownguide.org/basic-syntax/">Markdown</a> used to write this article, where ## Level 1 (The basics) makes a header, *Text* makes the text Italic, HTML is a markup language that is used in web pages, with its own rules and options. A small example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39bcc5052e6b6a83a071f39038178dd1/href">https://medium.com/media/39bcc5052e6b6a83a071f39038178dd1/href</a></iframe><p><a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started"><em>Introduction to HTML/Getting started</em></a></p><p>But, even though this page would work on its own on any browser, and would output a “Hello, World!” to the screen, it doesn’t look good, it looks plain, HTML alone can hardly show good looking content that provides good user experience, it cannot specify colors, sizes, effects, structures specific to a screen (Useful for responsive design), that’s where CSS comes in. <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/First_steps/What_is_CSS">CSS</a> (Cascading Style Sheets) allows you to modify the looks and animations to an HTML document, you can assign properties to your HTML elements, properties like color, padding, margin, width, height, shadows, backgrounds, animations, etc..</p><p>With both HTML and CSS, you can create beautiful looking and vibrant pages, from the first look, you might even think that this page is missing nothing, so, where does Javascript fit in? HTML and CSS are not programming languages, they cannot comprehend complex logic, for example, you cannot disable a button somewhere in the page, because a set of inputs elsewhere is not fulfilled and verified, even somewhat complex validation cannot be handled by HTML and CSS, <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps">Javascript</a> is the <a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS">Object Oriented</a> logic behind every page, it tells the page to do this if that, show these if this, in Javascript world, you can create states (variables), modify them conditionally, make API calls, and use all of that to modify your HTML document dynamically.</p><h3>Level 2 (What’s all this for?)</h3><p>Okay now, you know what HTML, CSS and Javascript are, you know how to create somewhat good looking pages, maybe you know how to create a few animations with CSS, and how to create a simple calculator with Javascript, but now you’re thinking, how do I begin to employ this? What’s all this for? If you browse the internet for a few hours, just explore, not setting your sails to a specific target nor destination, you’ll find fascinating web animations, catchy UI, restaurants around you, websites that calculate your BMI, the time it would take to download F.R.I.E.N.D.S over a 100 KB/s network, or the number of casualties if you throw different nuclear bombs over your roof. All this variation is permitted by the wonders of programming, but while it looks like hieroglyphic texts that summon magic to cart your month’s salary, it’s really just a set of sequential commands that moves your website from one state to the next.</p><h3>Level 3 (My first “Hello, World!”, Again.)</h3><p>Here, you know how to create simple web pages, you can deliver UI as per specifications, and you’d like to push your career further, you’d like to know more. Javascript is quite powerful, but with all the power it has, writing pure Javascript code is bound to lack scalability, it is very hard to maintain large websites if — God forbid — you were using pure Javascript, so now, you start thinking about expanding. The market offers a few options that you can look into, these include <a href="https://reactjs.org/docs/getting-started.html">ReactJS</a>, <a href="https://docs.angularjs.org/guide">Angular</a>, <a href="https://vuejs.org/v2/guide/">Vue.js</a>, and several more. And you remember that a few of your friends are encouraging you to dive into React, you do a little research, and dive head first. ReactJS is a Javascript library used for building UI, the core concept of React, is to have your website abstracted to smaller reusable components. Like Buttons, Inputs, Cards, Tables, anything you can have on your website can be abstracted to components, and the more powerful feature, is that components can compose of other components. For example, you can have a Label componet, an Input component, and a Field component that consists of both the Label and the Input, like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9e9de7897628d46c219abcdb7dcbbde/href">https://medium.com/media/b9e9de7897628d46c219abcdb7dcbbde/href</a></iframe><p>This allows you to simply reuse components anywhere across the application, turn features on and off more easily, and edit features across the entire application with ease.</p><h3>How does react work?</h3><p>A react application has a simple html page, ideally containing a bunch of metadata for CEO, a huge javascript bundle file, and a</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ffe2769ba18d3bf4baec34778ea0707/href">https://medium.com/media/6ffe2769ba18d3bf4baec34778ea0707/href</a></iframe><p>This is all the HTML React needs to function, the rest, your entire web page, is dynamically generated by the bundle.js file, all your elements are generated on demand, once your bundle is loaded. This concept revolutionized web development, and despite the limitation it had at its beginning, specifically SEO compatibility, the technology exploded in popularity due to its impressive scalability. Now you can use beautiful UI components — E.g <a href="https://ant.design/docs/react/introduce">AntDesign</a> — and integrate them with your website in no time, the cost of adding a new feature decreased by a lot, you suddenly could manage large websites with hundreds of custom components more easily.</p><h3>Level 4 (Fundamentals of React Development)</h3><p>After having learnt what React is conceptually, you dive into code, now there are a few things you need to learn about:</p><h3>1. JSX</h3><p>This code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/933cb2b80aaeeeb5306ade98c6ef42fe/href">https://medium.com/media/933cb2b80aaeeeb5306ade98c6ef42fe/href</a></iframe><p>Does not contain HTML, despite having very similar syntax, your elements inside a React component are an extension of Javascript, called JSX, the key difference is that JSX is stored in something called <strong>Virtual DOM</strong> and kept in sync with the real DOM, while HTML is directly outputted to the real DOM, more on that later.</p><h3>2. Functional vs Class</h3><p>A small example for both:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e47cd5b61bb42a4aed0415152481897/href">https://medium.com/media/4e47cd5b61bb42a4aed0415152481897/href</a></iframe><p>Both these components would output similar UI and functionality, ever since React 16.8 (2019) update, the need for class components diminished, they looked more complicated for too little gain, functional components used to be called “stateless” because they couldn’t hold a state like class components do, but since <a href="https://reactjs.org/docs/hooks-intro.html">React Hooks</a> were introduced in the update, functional components could do anything a class component can. Perhaps the following section is more history than technicality, but it gives you an idea about what re-rendering means. In class components, there are a few methods that are called <a href="https://reactjs.org/docs/react-component.html#the-component-lifecycle">lifecycle methods</a>, these methods are invoked on a particular action each, for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cadf8a94fa70a2a9198ef7215ff8a991/href">https://medium.com/media/cadf8a94fa70a2a9198ef7215ff8a991/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cadf8a94fa70a2a9198ef7215ff8a991/href">https://medium.com/media/cadf8a94fa70a2a9198ef7215ff8a991/href</a></iframe><p>These are only some of the life-cycle methods, as you noticed, some methods do care about their return, like render, which updates the return value in the virtual DOM, shouldComponentUpdate, which will update if a truthy value is returned, and won&#39;t otherwise. While others don&#39;t care if you return anything or not, like componentWillMount. The core idea behind these methods is that a given component will internally perform some computation on a given trigger, the trigger can be that the props are updated, or that the component is mounted/unmounted, or that the state is changed.</p><h3>Rendering</h3><p>A component’s render updates the virtual DOM with the new view, and the virtual DOM in turn is synced up with the “real” DOM, a component assumes that the view is changed when the props/state/mounting is changed, which is not necessarily the case, you’ll see now a case where the props do change, but the view shouldn’t.</p><p>Ideally, for optimal performance, you will want your component to perform only necessary renders, take this as an example of what poor performance would look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/830856aadf29e50c1915d7c1bc3d8582/href">https://medium.com/media/830856aadf29e50c1915d7c1bc3d8582/href</a></iframe><p>In this example, we have a simple clock that displays the date and time, considering the functionality, the component should ideally be rendered once every minute, because that’s when the view is going to change, rendering it every second is useless, and even more wasteful, 10 times/second. To fix that, we need to adjust the Clock component to be as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65d0ae3175cf3188a313a5bf14fea1ba/href">https://medium.com/media/65d0ae3175cf3188a313a5bf14fea1ba/href</a></iframe><p>Here, we’ve used React.memo to tell the component when to render, the same old component is passed, but along with a function whenToRender, one bit confusing thing about this function, is that it will render if you returned false, and won&#39;t if you returned true, opposite to shouldComponentUpdate, and that&#39;s because the function isn&#39;t intended to mean</p><blockquote><strong>“When to render?”</strong></blockquote><p>but</p><blockquote><strong>“Are the previous props the same as next props from the perspective of the component? If yes, then no need to render”</strong></blockquote><h3>Hooks</h3><p>We’ve already used some of these in the previous examples, but let’s dig in a bit deeper into React hooks. React hooks is a feature that was introduced in React 16.8 that made functional components a lot easier and more versatile to use.</p><h4>Basic hooks (useState, useEffect, useMemo)</h4><p>Consider the following component that uses these hooks:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/261727267469651568b6186b4484b3a3/href">https://medium.com/media/261727267469651568b6186b4484b3a3/href</a></iframe><p>Here, we’ve used a useState to create our custom state specifically for this component, useEffect to trigger a certain function (our loadUsers) given a certain dependency (Here, no dependencies were specified, so it&#39;s going to be triggered only on mounting), and a useMemo, which does certain expensive computations only when needed, independent of component rendering.</p><h4>Custom hooks</h4><p>It is very likely that you’ll need a certain manipulation using hooks to be common across at least some components. For example, take this case: You use modals quite a lot, and you always do this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1df4bccfbde4cdb9ea1ee6216a96c2e5/href">https://medium.com/media/1df4bccfbde4cdb9ea1ee6216a96c2e5/href</a></iframe><p>So, you think, is there an easier way to bundle this particular functionality into one hook? You want to say something like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1958fc72e5d2eaa0d1609aeb2c774e2e/href">https://medium.com/media/1958fc72e5d2eaa0d1609aeb2c774e2e/href</a></iframe><p>And the answer is yes, there is. This is the syntax for creating a custom hook:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24ce899d5e5960cf6b6e3e103a7e0e00/href">https://medium.com/media/24ce899d5e5960cf6b6e3e103a7e0e00/href</a></iframe><p>And just as simple as that, you can say</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c3d8353372faa3b20837146d88f8331/href">https://medium.com/media/5c3d8353372faa3b20837146d88f8331/href</a></iframe><p>Another quick example before we hop into explanation You frequently call backend APIs, and for every API, you create a loading state, and manipulate that loading state before calling the function, and in the then and catch of that function, as in:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e566f14d29d08c743ccaa4e9c4d6702d/href">https://medium.com/media/e566f14d29d08c743ccaa4e9c4d6702d/href</a></iframe><p>Here, you look at this, and think how ugly it is to handle the loading state like this in every component, especially if you had multiple calls you want to handle, and each would have its own state and setter function. First, you ask yourself “What would a more convenient code look like?”, and maybe you think it’s this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/972f29d5071e00369d769a0435696e01/href">https://medium.com/media/972f29d5071e00369d769a0435696e01/href</a></iframe><p>Then you think “Okay, I know what I want the hook to look like, how do I write it?” And that’s how:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb923dce6d60298f8afae3d5e2aa3d96/href">https://medium.com/media/bb923dce6d60298f8afae3d5e2aa3d96/href</a></iframe><p>And this hook should work exactly as we want it to. <a href="https://reactjs.org/docs/hooks-intro.html#its-hard-to-reuse-stateful-logic-between-components">The idea behind custom hooks</a> should be clear now, hooks are a way to reuse a component’s stateful logic, and manage some general form of state independently of the component’s own logic and implementation. A <a href="https://reactjs.org/docs/hooks-intro.html#its-hard-to-reuse-stateful-logic-between-components">custom hook</a> <strong>must</strong> start with “use”, it’s not a component, but you may call React hooks within a custom hook, and of course, you may call other custom hooks within a custom hook.</p><h3>3. React Context</h3><p>As it stands, React is quite powerful and versatile, but there’s a fundamental issue with React that increases the complexity of any given project, and issue is state management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T_0cm4WlncmmX6Lf.png" /></figure><p>Imagine this scenario, you have your component tree, and there’s some state that component Y is interested in, a state which component X owns, you can imagine this being some expensive API call which is fetched when component X has loaded, and component Y wants to make use of.</p><p>The process of moving the state from X to Y is quite bothersome, as the state will have to traverse the component tree, up to the nearest common ancestor component, and then back down to component Y. The process would generally look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WN8sGEkeLea_KS0J.png" /></figure><p>And in code, you’ll have to pass down function onChange from D to X, then from B to D, and from A to B, then you&#39;ll have to pass down the updated state from A to C, then C to F, then F to Y. Just saying it sounds complicated, you wouldn&#39;t think the code could be any simpler!</p><p>You can think of React context as a store that saves and distributes data only to the components interested in that change, these components are identified by being wrapped by special components provided by the context called <strong>Provider</strong> that defines the state, and <strong>Consumer</strong> that reads or updates that state, see the following example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64edb8b763a53b7bb7c1167bcd59ed38/href">https://medium.com/media/64edb8b763a53b7bb7c1167bcd59ed38/href</a></iframe><p>Here, the Provider is given to A, and consumers are given to all components that want to modify the context, i.e. to X and Y, and each reads or modifies the state accordingly, and all consumers and the provider are expected to get every update to the context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OPmeQt0zcRM-Miz8.png" /></figure><p>This expensive visual illustration shows how the state is transmitted between X to Y, without the need to go over the entire component tree. As you might’ve guessed, this not only simplifies the code and makes it more readable, but it also improves performance quite noticeably.</p><p>Using React context isn’t the only approach tho to achieve state management, there are multiple libraries that handle state change across multiple components, they usually share the idea of a centralized store, like Redux and Mobx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zS2JCWdJ7GoHg8l2.png" /></figure><p>The usage of context, Redux, Mobx, or any other state management library is dependent on the project you’re working on, small simple projects may not need state management at all, and anything more than that will probably need state management on the short on long run.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d14cfc2eb910" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>