<?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 Ndukwe Armstrong on Medium]]></title>
        <description><![CDATA[Stories by Ndukwe Armstrong on Medium]]></description>
        <link>https://medium.com/@ndukwearmstrong?source=rss-4c22c48757a8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ulGI0iBW0T_UkOx00S2BAg.png</url>
            <title>Stories by Ndukwe Armstrong on Medium</title>
            <link>https://medium.com/@ndukwearmstrong?source=rss-4c22c48757a8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:33:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ndukwearmstrong/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[Introducing Fronclass: A Vehicle for Educational Transformation]]></title>
            <link>https://ndukwearmstrong.medium.com/introducing-fronclass-ai-a-vehicle-for-educational-transformation-1bf3b45ccfb2?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bf3b45ccfb2</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[science]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 11:53:36 GMT</pubDate>
            <atom:updated>2026-06-01T12:43:31.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NKXWt78ZM6HlXSzJ6f5ww.png" /></figure><p>For decades, the promise of the digital revolution in education was simple: equality of opportunity. But as we stand at the precipice of the AI era, that promise has hit a jagged reality. Instead of narrowing the gap, the rapid influx of high-cost, high-bandwidth AI tools has created a new digital canyon. In Africa and across the developing world, the majority of students find themselves on the wrong side of that divide: distracted, disorganized, and increasingly backward in global knowledge.</p><p>At the same time, even in the elite circles of education, a different kind of frustration brews. Educators are overwhelmed by a sea of “vibe-coded” apps that offer plenty of flash but little functional depth. The system is at a breaking point.</p><p>This is the exact moment <strong>Frontclass AI</strong> was built for. We aren’t just launching another software; we are deploying a vehicle for national transformation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DjuUpXboQ1x4POIO.png" /></figure><h3>The “Breaking Point” Behind the Vision</h3><p>The story of Frontclass AI doesn’t begin in a sleek boardroom; it begins in the middle of a struggling classroom. Our founder, <strong>Ndukwe Armstrong</strong>, witnessed firsthand the quiet tragedy of the “frustrated genius”: smart, hardworking students held back by an environment that couldn’t support their potential. He saw brilliant lecturers who loved their craft but lacked the materials and infrastructure to deliver it.</p><p>“<em>Africa is mine, and I’m gonna build it,” </em>Armstrong often says. <em>“Society may not be equal, but opportunity should at least be accessible to everyone.”</em></p><p>That conviction led to the creation of a platform designed to address the frustrations of both the educator and the student in one go. Whether it is a public school student trying to catch up with global standards or a professional at a leadership school seeking 10X performance, Frontclass AI provides the ladder.</p><h3>Beyond the Tool: Polymorphic Learning and Offline Resilience</h3><p>What makes our solution fundamentally different is that we didn’t build it to fit a profit-and-loss sheet; we built it to fit into human lives. Some people misunderstand the problem, viewing education through a narrow lens of video clips and quizzes.</p><p>Frontclass AI introduces <strong>Polymorphic Teaching: </strong>a system where learning formats adapt to the user, not the other way around. This allows for a seamless blend of remote teaching, AI-driven Learning Management Systems (LMS), and networking.</p><p>Crucially, we understand that the world isn’t always “online.” Our “Offline-First” support ensures that a lack of stable internet isn’t a barrier to a world-class education. Our low-level systems engineers have crafted a high-tech engine that runs deep, stays affordable, and localizes to the specific needs of any region.</p><h3>The Shift: From Struggle to Success</h3><p>Before Frontclass AI, a student’s life often looked like a series of missed connections. Take Adora Precious, a Chemical Engineering student: <em>“I did badly at a course because my lecturer had no materials to share and he taught so badly,”</em> she recalls. <em>“I wish I had this software; it would have helped me prepare and understand the subject.”</em></p><p>After Frontclass AI, that narrative changes. The frustration caused by insufficient materials, shallow lectures, and a lack of engagement is now completely eradicated. Also, Abraham Prince, a high school student, notes: <em>“I can easily understand physics with it… it’s better than the AI tools my school is using.”</em></p><p>We are moving from a world of dropouts and backward knowledge to a future where students are ahead of the competition before they even graduate.</p><h3>The Future of the Future</h3><p>In three to five years, success for Frontclass AI won’t just be measured in user counts or revenue. It will be measured in the closing of the digital gap. It will be seen in the rise of a new generation of leaders who have the tools to compete globally from exactly where they were born.</p><p>Education is the future of Africa, and by extension, the future of the global talent pool. By building ladders for growth and providing AI accessibility to the “vast majority,” we aren’t just changing how people learn; we are changing what they can become.</p><p>The headline of the future won’t just be about a successful startup. It will be about a continent, and a generation, finally catching up to its own potential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UBzfRblhukrKOSeFujDzgA.png" /></figure><p>Ready to transform your learning experience?</p><p><strong>Visit our website:</strong> <a href="https://www.frontclass.cloud/">www.frontclass.cloud</a></p><p><strong>Follow the journey on LinkedIn x WhatsApp Community:</strong></p><p><a href="https://www.linkedin.com/company/frontclass/">https://www.linkedin.com/company/frontclass/</a></p><p><a href="https://whatsapp.com/channel/0029Vb77GjSAjPXOKU8IwO42">https://whatsapp.com/channel/0029Vb77GjSAjPXOKU8IwO42</a></p><p><strong>Direct Inquiries:</strong> info@fronclass.cloud</p><p><strong>For Educators &amp; Trainers: </strong><a href="http://www.frontclass.cloud/educators">www.frontclass.cloud/educators</a></p><p><strong>For Schools &amp; Institutions:</strong> <a href="http://www.frontclass.cloud/educators#enterprise">www.frontclass.cloud/educators#enterprise</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bf3b45ccfb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The OR-channel Pattern w/ Dynamic Selects]]></title>
            <link>https://ndukwearmstrong.medium.com/the-or-channel-pattern-w-dynamic-selects-ae2c52fe1cfd?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae2c52fe1cfd</guid>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Sat, 30 Aug 2025 20:50:38 GMT</pubDate>
            <atom:updated>2025-08-30T20:50:38.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*UMaMf9uoD-QS7xGAPsDZPw.webp" /><figcaption>credit: <a href="https://www.softwebsolutions.com/wp-content/uploads/2020/10/golang-Programing.jpg">https://www.softwebsolutions.com/wp-content/uploads/2020/10/golang-Programing.jpg</a></figcaption></figure><p>This read will be so beneficial if you are a senior Golang engineer or if you are building some complex systems on Go that involve concurrency.</p><p>We will divide the article into two parts: <strong>Part 1</strong> will be about the OR-Channel pattern in its raw recursive form, and <strong>Part 2</strong> will be about a more intuitive way of implementing it, which is the juicy part of our conversation.</p><p><em>☕️☕☕️☕️ ️grab your coffee and let&#39;s hit the ground running!!! 🙂🙂</em></p><h3><em>Part 1: OR-Channel Pattern</em></h3><p>If you have multiple channels and you want to “do something” if at least 1 of them resolves (returns), the go-to way to do that is the <em>OR-Channel Pattern.</em></p><p>In the <em>OR-Channel Pattern, </em>we simply have a function that takes a list (what we call a slice) of channels and returns a single <em>receive channel </em>we wait on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AktE86gV03w1L-HHj1cYoQ.png" /><figcaption>The OR-function</figcaption></figure><p>That&#39;s simply what the OR-Channel pattern is about in a nutshell, and this is how it&#39;s implemented recursively:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ej3J6wulgE6_yFHc0Davlg.png" /><figcaption>The implementation of the OR-Channel Pattern (Recursion)</figcaption></figure><p>uuuussh 🤦🏼‍♂️…!!!! This looks a bit complicated already. Let’s dive into it bit by bit.<br>The catch here is in the <em>orDone-</em>channel on line 10, it returns at line 28, that is the channel we actually listen to once any of the other channels returns a value, and then we pass that recursively to the others on line 24, so new recursive functions also create a new <em>orDone-</em>channel and remember we have passed the previous <em>orDone-</em>channel so if the previous returns the linked recursive function also returns(becuase of the <em>select {…}</em>)so that way we have a chain of functions or links.<br>More like you pass a ticket with a <strong>key T1</strong> to Mr A, and Mr A creates a new <strong>key T2 </strong>and packages the ticket and the old key T1 to Mr B, and on and on…</p><blockquote>Key T1, T2 is the <em>orDone-</em>channel in my illustration above</blockquote><p>hmmmm…!!!! This is already a lot, but it will be relatively understandable if you have a good grasp of recursion, data structures, and algorithms.</p><h3>Part 2: Dynamic Select (Intuitive OR-Channel Pattern)</h3><p>I personally call this the <em>*Intuitive OR-Channel Pattern* </em>because at first glance, you can easily understand what the code does, no recursion, less boilerplates, easy to implement, gives you more control, and helps you model your application more intuitively.</p><p>🏃🏼‍♂️ Alright, let&#39;s go!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMKbQymqksSg4b0XYT0J6w.png" /><figcaption>Dynamic Select-Case</figcaption></figure><p>🙂 So basically here we are using the built-in Go&#39;s <em>Reflect.Selectcase, </em>it<em> </em>is used when you have an unknown number of <em>cases.</em></p><p>On lines 8–15, we are basically creating a slice of <em>Reflect. Selectcase, </em>we then loop through the channels list and create a case for each of them, which is just a struct with properties of:</p><ol><li><strong>Dir</strong>: Dir representing the direction of the channel; receive/send. For our use case, it is a receive channel, so a type of <em>reflect.SelectRecv</em></li><li><strong>Chan</strong>: As the name implies, the actual channel but a type of <em>reflect.Value</em></li></ol><p>On lines 17–27, we create a goroutine to listen for the values from channels(or cases).</p><p>Line 18 is actually blocking; it blocks till one of the cases resolves, so if you want to get all the values from the channels, you can use a for loop (<em>for len(cases) ≥ 0 {…}</em>), but since our use case is to return once any of the channels is ready, so once we get a value, we just return.</p><blockquote>Note, the value you get from <em>reflect.Select(cases) </em>is of a type of <em>reflect.Value</em>, so we convert to int, and that panics if the underlying value is not an int, but you can confirm that with value.kind.</blockquote><p>Here’s the full code: <a href="https://github.com/armstrong99/Content-World/blob/main/medium/Go/main.go"><em>https://github.com/armstrong99/Content-World/blob/main/medium/Go/main.go</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQ8K4p6ixaedqMHlkPmFPA.png" /></figure><p>When does this become very handy:</p><ol><li><strong>Timeouts and Cancellation</strong>: Stop work if a request, timeout, or cancel fires first. <em>&lt;-or(apiRespChan, time.After(2*time.Second), ctx.Done())</em></li><li><strong>Racing Multiple Sources</strong>: Take the fastest response from multiple providers <em>&lt;-or(provider1(), provider2(), provider3())</em></li><li><strong>Failover Systems:</strong> Use the first healthy replica that responds. <em>&lt;-or(replica1Query(), replica2Query(), replica3Query())</em></li><li><strong>User Input vs. Timeout:</strong> Wait for input or fallback to default.<em>&lt;-or(userInputChan, time.After(5*time.Second))</em></li><li><strong>Graceful Shutdown:</strong> Exit on first shutdown signal. <em>&lt;-or(sigIntChan, sigTermChan, ctx.Done())</em></li><li><strong>Any success Jobs:</strong> Return the result as soon as any worker finishes.<em>&lt;-or(worker1(), worker2(), worker3())</em></li></ol><p>👍🏻 Great job if you read to this point. Learning is better together✨✨ — so if you enjoyed this, drop a like 👍, clap 👏, and follow me for more. I’d love to hear your thoughts too, so let’s connect on <a href="https://www.linkedin.com/in/ndukwearmstrong/">LinkedIn</a> and keep the discussion alive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae2c52fe1cfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advancing Your Career as a Backend Engineer in 2024]]></title>
            <link>https://ndukwearmstrong.medium.com/advancing-your-career-as-a-backend-engineer-in-2024-33af48c80c76?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/33af48c80c76</guid>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Tue, 19 Mar 2024 14:05:31 GMT</pubDate>
            <atom:updated>2024-03-19T14:55:58.915Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, 👋 welcome to the year 2024. If you are reading this, I know you desire to grow in your career as a backend engineer. In this article, I will cover a few ways to take your career as a backend engineer to the next level. Without further ado, let&#39;s hit the ground running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VM57iNZ_QG9VhRStn4Fy_g.png" /><figcaption>Ndukwe Armstrong’s Quote</figcaption></figure><h3>Learn Another Language</h3><p>Every 10x engineer I&#39;ve seen out there is a master of a language but still has basic knowledge and sometimes even mid-level knowledge of some other programming language. This is useful because it makes you see things differently and gives you a firm foundation in engineering as a whole.<br>I remember working for a US-based startup, and we had an issue with a lambda functionality written in NodeJS, It was breaking for several technical reasons I can’t explain here, but I had an idea to implement it in Python since the SDK itself was even broken internally. And it was a big win for the team. So in all your mastering, pls learn at least the basics of another programming language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9zElD-c_RYJKrNZWWxLGA.jpeg" /><figcaption>Linux</figcaption></figure><h3>Learn Linux</h3><p>You see, that yellow-looking toy right there is a game-changer for the tech industry. pls master Linux commands and study the basics of operating systems. There’s a common joke that the reason why SpaceX uses Linux is because you can&#39;t open windows in space.<br>As you build enterprise applications for thousands and even millions of users, you will need a fast and well-controlled environment to build your application.<br>I worked for a company lately, and we have to open thousands of TCP/UDP ports for some technical reasons I can’t go into detail about. I tried this in Windows and macOS; you can&#39;t even do that in development, but Linux is a big win for everyone because it&#39;s more like a terminal on steroids. The level of control it gives is just enormous to talk about here, from file watching to scripting, cron jobs, file editing, etc. <br>To begin, just get familiar with the Linux commands, &amp; I think it&#39;s the core skill to have in that regard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*6YhAWtDccDz9QJXsLpvbTg.png" /><figcaption>GeeksForGeeks DS Image</figcaption></figure><h3>Learn DS &amp; Algo Deeply</h3><p>I jokingly say, when with my friends, that I can&#39;t employ someone who doesn&#39;t have a good foundation in data structures (DS) and algorithms (Algo).<br>Having a good knowledge of BigO and how it applies to your domain (e.g., NodeJS engineering) is a big upgrade for you as a developer, because why on earth will one write programs or codes, and you can’t tell how well they perform, how fast they will be, or how they change with size (e.g., inputs and parameters) over time?<br>So don&#39;t just learn sorting algorithms and feel, <em>oh! man, I&#39;m good, </em>nah! keep improving and try to solve problems on trees, graphs, greedy algorithms, and dynamic programs, lol 😃 I&#39;m smiling because DP (dynamic programming) algos are very crazy; if not careful enough, they can sweep you off your feet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lVzjSRNmsaj48yWsj2UaQ.jpeg" /><figcaption>Chips X Nvidia</figcaption></figure><h3>Understand Engineering Principles</h3><p>Well, this is one core difference between senior or chief engineers and juniors. Seniors understand how engineering works at the root level in a very unique and personal way as it relates to their domain.<br>Understand principles, why NodeJS is single-threaded and how true that is, what the difference is between TCP and UDP, what garbage collectors exist, how my code has been compiled, etc. These are some low-level questions you should be asking and trying to experiment with. So don&#39;t just do things, but be hungry enough to find the why behind it; that way, you will upskill yourself in the industry.</p><p>When you start mastering principles, you realize why there are so many tools and libraries out there and how easy they become to learn and use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*3IrVpxzLSrnVEalWidJpHg.jpeg" /><figcaption>Lib</figcaption></figure><h3>Appreciate Documentation</h3><p>Most upcoming developers always love YouTube videos and are always looking forward to the next beautiful article. Well, that&#39;s all good, but if you want to get into the deep waters of your career as a backend engineer, be ready to study a lot. Several libraries and tools are versioned, and each version comes with new features. A YouTube video or article may not cover all the little, tiny details that you may need or make you stand out. So always look out for docs and study them, I know it&#39;s not a nice experience 😏 but you gat no choice because paying attention to little details makes you a great engineer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NiEJ-Vtyok8_BkRls2EQAA.png" /><figcaption>Linkedin post</figcaption></figure><h3>Keep Networking &amp; Stay Humble</h3><p>Well, what you just read happens now and then. You want to take your career to a new height:</p><ul><li>Always help others. It may not be your language but of course, the principles are always the same, so never be too busy to render help</li><li>You want to be a senior, have other senior and pro engineers as friends and colleagues; don&#39;t always be the ONLY beast in your circle</li><li>Stay humble and keep asking questions</li></ul><p>Well, there’s a lot to say and talk about when it comes to career growth, but I think from personal experience that if you keep to the few things I have shared, it can make a significant difference in your career. So keep building and developing, You can find me on LinkedIn for more interesting posts and tips. <br>🔗 <a href="https://www.linkedin.com/in/ndukwearmstrong/">https://www.linkedin.com/in/ndukwearmstrong/</a><br>🔗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33af48c80c76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Referencing or Value Coping C++/TypeScript]]></title>
            <link>https://ndukwearmstrong.medium.com/referencing-or-value-coping-c-typescript-4f8ea88b7675?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f8ea88b7675</guid>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 23:14:57 GMT</pubDate>
            <atom:updated>2023-06-28T23:14:57.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0IW2_6jrfRa1lNva_Nywjg.png" /><figcaption>TypeScript C++</figcaption></figure><p>In today&#39;s article, I share an insightful concept in C++ and how we can achieve that in TypeScript, This can be applied across any Javascript environment — Node, React, Vue, etc. Grab a cup of ☕️ coffee and let&#39;s hit the ground running 🏃‍♀️</p><h4>References &amp; Value Copy</h4><h4>About C++ Pointers</h4><p>C++ is the mother of all languages, as they say, and although not in everyday use anymore, her concepts have been part of the development of many other languages over decades. One of these important concepts and unique features of C++ is its ability to manage and manipulate memory. For example, we can even print out the memory address at which a value is saved using the address-of, &amp; , operator, which is currently not available in JavaScript (Nodejs):</p><pre>#include &lt;iostream&gt;<br><br>int main() {<br><br>    int num = 12;<br><br>    int* ptr = &amp;num;<br><br>    // Print the memory address of the variable<br>    std::cout &lt;&lt; &quot;Memory address of num: &quot; &lt;&lt; &amp;ptr &lt;&lt; std::endl;<br><br>    std::cout &lt;&lt; &quot;Actual value of num: &quot; &lt;&lt; num &lt;&lt; std::endl;<br><br>    return 0;<br>}</pre><pre>Memory address of num: 0x16fdff2f0<br>Actual value of num: 12</pre><p>When we get the address of a variable, we usually assign it to another kind of special variable called Pointers , Pointers allow us to dynamically allocate and manipulate memory. Consider the code below:</p><pre>#include &lt;iostream&gt;<br><br>int main() {<br><br>    int *numPtr = new int(10);<br><br>    std::cout &lt;&lt; &quot;Value: &quot; &lt;&lt; numPtr &lt;&lt; std::endl; <br>    <br>    int newNum = *numPtr;<br><br>    std::cout &lt;&lt; &quot;Value: &quot; &lt;&lt; &amp;newNum &lt;&lt; std::endl;<br><br>    return 0;<br>}</pre><pre>Value: 0x100106220<br>Value: 0x16fdff2ec</pre><p>In the code above, we have a main method, on the first line, we define a pointer *numPtr and assign it to an integer 10. The pointer variable will hold the memory address of the stored value. We can even use the numPtr variable to update the value of 10 to whatever integer we like. On the third line, we have a new variable, newNum , we will be assigning the value of the pointer to this variable using a method called <em>dereferencing, </em>hope you noticed the asterisks (*) added in front, This way,newNum holds is assigned with a completely different memory address with the value 10, It’s easy-peasy!👌🏻</p><h4>JavaScript Objects</h4><p>Moving down the lane to JavaScript, we have a different story in how memory is managed, code is executed, and garbage collection works.</p><p>Here are a few facts about NodeJS:</p><ol><li>Works with two types of memory—stack and heap memory.</li><li>JavaScript has two major classes of values: primitives (numbers, booleans, strings, etc.) and objects (arrays, objects, etc.).</li><li>An execution context: The execution context is an internal JavaScript engine construct that holds information about the execution of code. It is a concept used to manage the creation and execution of code within the JavaScript runtime environment</li></ol><pre>export interface IPerson {<br>    name: string,<br>    age: number,<br>    married: string<br>}<br><br>const num = 10;<br><br>let Person: IPerson = {<br>    name: &quot;Armstrong&quot;,<br>    age: 23,<br>    married: &quot;single&quot;<br>}<br><br>const anotherPerson = Person<br><br>anotherPerson.name = &quot;John Doe&quot;<br><br>console.log(Person.name) // &quot;John Doe&quot;<br></pre><p>The above code is typescript, but in reality, it compiles first to JavaScript. So when executing this code line by line in the execution context, Javascript creates a variable num with a value of 10, for the Person object it creates the values in the heap memory and stores the reference only to this Personvariable.</p><p>This is why <em>[] === [] </em>is<em> false, </em>because although they are both empty arrays, in the execution context their references or addresses from the heap are different and considered false.</p><p>Here’s a problem with this JavaScript default design on handling memory and objects: in the last line, even if we assign another variable anotherPersonand change some properties, say the name property, the Person parent object also gets updated, Why 🤷🏼‍♂️ I guess we know by now that both variables have the same memory address and point to the same object in the heap—same reference everywhere. But how do we walk around this if we really need to <em>copy by value?</em> Let&#39;s look at a few methods below:</p><h4>Spread Operator</h4><p>The spread operator does a lot of beautiful things for modern-day Javascript developers, but one of those in the context of our discussion is that it actually creates a new object (as per memory reference) with the same values.</p><p>So let&#39;s update our code snippet above to use the spread operator:</p><pre>export interface IPerson {<br>    name: string,<br>    age: number,<br>    married: string<br>}<br><br>const num = 10;<br><br>let Person: IPerson = {<br>    name: &quot;Armstrong&quot;,<br>    age: 23,<br>    married: &quot;single&quot;<br>}<br><br>const anotherPerson = {...Person}<br><br>anotherPerson.name = &quot;John Doe&quot;<br><br>console.log(Person.name) // &quot;Armstrong&quot;<br><br>console.log(anotherPerson.name) // &quot;John Doe&quot;</pre><p>That works 👏🏻 let&#39;s try another method:</p><h4>Object.Create Method</h4><p>This is an inheritance method, it takes an object and makes it the _prototype_ of another object</p><pre>export interface IPerson {<br>    name: string,<br>    age: number,<br>    married: string<br>}<br><br>const num = 10;<br><br>let Person: IPerson = {<br>    name: &quot;Armstrong&quot;,<br>    age: 23,<br>    married: &quot;single&quot;<br>}<br><br>const anotherPerson = Object.create(Person)<br><br>anotherPerson.name = &quot;John Doe&quot;<br><br>console.log(Person.name) // &quot;Armstrong&quot;<br>console.log(anotherPerson.name) // &quot;John Doe&quot;</pre><h4>Object.assign Method</h4><p>This method takes a <em>target</em> object and adds the enumerable properties of that other object to the target. For this case, let&#39;s make our target object an empty object, {} :</p><pre>export interface IPerson {<br>    name: string,<br>    age: number,<br>    married: string<br>}<br><br>const num = 10;<br><br>let Person: IPerson = {<br>    name: &quot;Armstrong&quot;,<br>    age: 23,<br>    married: &quot;single&quot;<br>}<br><br>const anotherPerson = Object.assign({}, Person)<br><br>anotherPerson.name = &quot;John Doe&quot;<br><br>console.log(Person.name) // &quot;Armstrong&quot;<br><br>console.log(anotherPerson.name) // &quot;John Doe&quot;</pre><blockquote>Similarly, all discussed so far also applies to arrays</blockquote><p>Hope! you learned something new and great by reading this article, This knowledge can be so useful as we build software utilizing recursive functions, classes, objects, listing, react engines, etc.</p><p>Keep reading, keep building, and keep on keeping on, Have a lovely day ahead ✌🏻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f8ea88b7675" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passing Data From Child to Parent Component in TypeScript React]]></title>
            <link>https://javascript.plainenglish.io/passing-data-from-child-to-parent-component-in-typescript-react-92ab6d03ceb1?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/92ab6d03ceb1</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Sat, 01 May 2021 10:57:27 GMT</pubDate>
            <atom:updated>2021-05-01T10:57:27.481Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c_otGxMhQQYeAODaylsf5A.png" /></figure><p>In modern-day front-end development due to its complexity and size, there’s a need for robust libraries, tools, and frameworks. With ReactJS we are able to effectively manage complex states, animations, frequent updates, and DOM manipulations. Typescript on the other has been a huge bridge to overcome most of the shortcoming of JavaScript such as been loosely typed.</p><p>In this article, I will be introducing to you how to pass data from a child component to a parent component in react using typescript, so grabs a cup of coffee and read on.</p><h3>Data Flow In React</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*RpIia3SaIKVxaa2G7Ch90g.png" /><figcaption>data flow | react</figcaption></figure><p>Basically react is designed to have a <strong>unidirectional </strong>data flow, this concept means that <strong>data</strong> has one, and only one, way to be transferred to other parts of the application i.e state is passed to the view and to child components.</p><p>below is a simple code snippet that shows the data flow</p><pre>// parent.tsx</pre><pre>const Parent:React.FC = () =&gt; {</pre><pre>const [parentName, setParentName] = useState&lt;string&gt;(&#39;John Obi&#39;)</pre><pre>return (<br>     &lt;div&gt;</pre><pre>       &lt;FirstChild name={parentName} /&gt;<br>       &lt;SecondChild name={parentName} /&gt;</pre><pre>     &lt;/div&gt;</pre><pre>  )<br>}</pre><p>This is one of the reasons states are usually moved to the top of the component tree so that they can be shared between components that need to access it.</p><p>Also, it&#39;s worthy to note that, with this general unidirectional data flow of react applications, a change in the state of a child component does not affect the parent but only the child and components that are children to that child if it has.</p><p>I will be introducing a basic way this shortcoming is been overcome, there are other ways, one of which is using a global store such as redux and the context API.</p><h3>Overcoming This Shortcoming</h3><p>firstly, let&#39;s define our children components of the parent component seen above</p><pre>// firstChild.tsx</pre><pre>interface IfirstChildProps {<br>  name: string</pre><pre>}</pre><pre>const FirstChild: React.FC&lt;IfirstChildProps&gt; = ({name}) =&gt; {</pre><pre>const [firstChildName, setFirstChildName] = useState&lt;string&gt;(&#39;&#39;)</pre><pre>return (</pre><pre>&lt;section&gt;<br>  &lt;h1&gt; {firstChildName} &lt;/h1&gt;<br> &lt;button&gt; first child &lt;/button&gt;<br>&lt;/section&gt;</pre><pre>)</pre><pre>}</pre><pre>export default FirstChild;</pre><p>In typescript you have to define types for everything, therefore, for our <em>firstChild</em> component, we declared her props to be of type <em>IfirstChildProps </em>and declared the <em>name</em> prop to be a string. we also gave it a local state of <em>firstChildName</em>, in the future, we will aim at making the local state value to be the state of her parent component.</p><p><em>Remember by default in react, you can only pass data or state in one direction i.e from parent to child component</em></p><p>now let’s declare the <em>secondChild</em> component in the same manner</p><pre>// secondChild.tsx</pre><pre>interface IsecondChildProps {<br>  name: string</pre><pre>}</pre><pre>const SecondChild: React.FC&lt;IsecondChildProps&gt; = ({name}) =&gt; {</pre><pre>const [secondChildName, setSecondChildName] = useState&lt;string&gt;(&#39;&#39;)</pre><pre>return (<br>&lt;section&gt;<br></pre><pre>  &lt;h1&gt; {secondChildName} &lt;/h1&gt;<br>  &lt;button&gt;second child&lt;/button&gt;</pre><pre>&lt;/section&gt;</pre><pre>)</pre><pre>}</pre><pre>export default SecondChild;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/155/1*GONFO_rvaI_-5HbtBkpD4Q.jpeg" /></figure><p>This just renders the buttons from the children components and an empy h2 html tag.</p><p>So at this point, we will add the <a href="https://reactjs.org/docs/hooks-effect.html"><em>useEffect</em></a><em> </em>hook to each child component, which sets the <em>parentName </em>prop(from the parent) as the value of the local state names(F<em>irstChildName</em>, S<em>econdChildName</em>) of her children.</p><pre>// firstChild.tsx</pre><pre>interface IfirstChildProps {<br>  name: string</pre><pre>}</pre><pre>const FirstChild: React.FC&lt;IfirstChildProps&gt; = ({name}) =&gt; {</pre><pre>const [firstChildName, setFirstChildName] = useState&lt;string&gt;(&#39;&#39;)</pre><pre>useEffect(() =&gt; {</pre><pre>  setFirstChildName(name)</pre><pre>},[name])</pre><pre> ...</pre><pre>export default FirstChild;</pre><p>pls note that the name prop is added to the dependency of the <em>useEffect </em>hook, with this, once the component mounts and anytime the name prop changes it will re-render the components</p><p>let’s do the same for the <em>SecondChild</em> component</p><pre>// secondChild.tsx</pre><pre>interface IsecondChildProps {<br>  name: string</pre><pre>}</pre><pre>const SecondChild: React.FC&lt;IsecondChildProps&gt; = ({name}) =&gt; {</pre><pre>const [secondChildName, setSecondChildName] = useState&lt;string&gt;(&#39;&#39;)</pre><pre>useEffect(() =&gt; {</pre><pre>setSecondChildName(name)</pre><pre>},[name])</pre><pre> ...</pre><pre>export default SecondChild;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*3PUzmKsoLqzAXq3usthJwQ.jpeg" /></figure><p>Now, we can see the name “ John Obi” from the parent component, rendering on both components</p><h4>Implementation</h4><p>At this point, we will implement our purpose — <em>passing data from the child to the parent component</em></p><p>let’s begin this by adding a helper function to the parent component. let’s name this function <em>updateName</em>, this function will accept an argument of type string and update the state of the parent component when called.</p><pre>// parent.tsx</pre><pre>const Parent:React.FC = () =&gt; {</pre><pre>const [parentName, setParentName] = useState&lt;string&gt;(&#39;Mr John Obi&#39;);</pre><pre>const updateName = (name: string):void =&gt; {<br>     setParentName(name)<br>}</pre><pre>return (<br>     &lt;div&gt;</pre><pre>      &lt;FirstChild name={parentName} /&gt;<br>      &lt;SecondChild name={parentName} /&gt;</pre><pre>    &lt;/div&gt;</pre><pre>)<br>}</pre><p>Alright, I think that was simple</p><p>Next, We pass this function as a prop to the children&#39;s components</p><pre>// parent.tsx</pre><pre>const Parent:React.FC = () =&gt; {</pre><pre>const [parentName, setParentName] = useState&lt;string&gt;(&#39;Mr John Obi&#39;);</pre><pre>const updateName = (name: string):void =&gt; {<br>     setParentName(name)<br>}</pre><pre>return (<br>     &lt;div&gt;</pre><pre>       &lt;FirstChild name={parentName} updateName={updateName} /&gt;<br>       &lt;SecondChild name={parentName} updateName={updateName} /&gt;</pre><pre>    &lt;/div&gt;</pre><pre>)<br>}</pre><p>woo! typescript should be yelling at you at this point for passing a prop not part of the prop type(interface) for the components, don&#39;t worry we will fix it in the next few paragraphs</p><p>we will simply add this <em>updateName</em> prop as part of the type definition(interface) of the props for each of the children</p><pre>// firstChild.tsx</pre><pre>...</pre><pre>interface IfirstChildProps {<br>  name: string,<br><strong>  </strong>updateName: (arg: string) =&gt; void</pre><pre>}</pre><pre>const firstChild: React.FC&lt;IfirstChildProps&gt; = ({name, updateName}) =&gt; {</pre><pre> ...</pre><pre>export default firstChild;</pre><p>Also, do the same for the S<em>econdChild </em>component</p><pre>// secondChild.tsx</pre><pre>...</pre><pre>interface IsecondChildProps {<br>  name: string,<br>  updateName: (arg: string) =&gt; void<br>}</pre><pre>const SecondChild: React.FC&lt;IsecondChildProps&gt; = ({name, updateName}) =&gt; {</pre><pre>...</pre><pre>export default SecondChild;</pre><p>I think we have come a long way, at this point we would add an onclick event to the button of each child, so that when clicked the <em>updateName </em>function will be called with a given string</p><p>let’s call our Fi<em>rstChild</em> component <strong>Micheal</strong>, and our <em>secondChild </em>Component <strong>David</strong>, so when the button in each of the children component is clicked, it shows the names, Micheal or David.</p><p><em>shall we?</em></p><pre>...</pre><pre>return (</pre><pre>  &lt;h1&gt; {firstChildName} &lt;/h1&gt;<br>  &lt;button onClick={() =&gt; updateName(&#39;Micheal&#39;)}&gt;first child&lt;/button&gt;</pre><pre>    )</pre><pre>}</pre><pre>export default firstChild;</pre><p>do the same for the S<em>econdChild </em>component</p><pre>...</pre><pre>return (</pre><pre>  &lt;h2&gt; {secondChildName} &lt;/h2&gt;<br>  &lt;button onClick={() =&gt; updateName(&#39;David&#39;)}&gt;second child&lt;/button&gt;</pre><pre>)</pre><pre>}</pre><pre>export default secondChild;</pre><p><em>Congratulations!, you just passed data to the parent from a child</em></p><p>Wow! so easy right? try clicking the buttons and see the names updating to either David or Micheal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/116/1*oI7rxuqHqAnHR8Q5Hce5xw.jpeg" /><figcaption>result when on the first-child button is clicked</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*z8MX0D34nm2ZheOfqN6Qqg.jpeg" /><figcaption>result when the second-child button is clicked</figcaption></figure><h3>Conclusion</h3><p>In general, react has a unidirectional data flow, i.e data is designed to flow in one direction — parent to children. But the basic strategy use to pass data the other way round is <em>passing and calling a function with the required data from the parent to the child component.</em></p><p>Hope you learned cool today, Thanks for reading this article, you can get the full code <a href="https://codesandbox.io/s/react-typescript-forked-j40t2?file=/src/index.tsx">here</a> and also follow me on <a href="https://twitter.com/AI_Lift">Twitter</a>, <a href="https://github.com/armstrong99">Github</a>, and <a href="https://www.linkedin.com/in/ndukwearmstrong/">Linkedin</a>, have a lovely day.</p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92ab6d03ceb1" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/passing-data-from-child-to-parent-component-in-typescript-react-92ab6d03ceb1">Passing Data From Child to Parent Component in TypeScript React</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Styling With ReactJS]]></title>
            <link>https://medium.com/geekculture/dynamic-styling-with-reactjs-7f7258d29cd0?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f7258d29cd0</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 14:01:32 GMT</pubDate>
            <atom:updated>2021-04-26T14:01:32.104Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RqP74lo8sDgMwZ4JXo9xBw.png" /><figcaption>ReactJS | UI</figcaption></figure><p>ReactJS is an amazing framework for developing user interfaces (UI) with complex states or logic going on. A good example of such logic or state is toggling between a dark and light theme.</p><p>In this article, I will be introducing how to dynamically style elements by changing their class names or CSS properties in response to an event(e.g onclick) or UI state</p><h3>About React’s Approach To UI</h3><p>Every interaction carried out on a web page is considered as an event in javascript. React as a library helps in managing these events, the application state, and updates with much and better performance.</p><p><em>let’s code</em></p><p><em>Ensure you have a react app already, or you can have one following the instructions </em><a href="https://reactjs.org/docs/create-a-new-react-app.html"><em>here</em></a></p><h3>Developing A Simple UI</h3><p>Firstly, open your App.css and add the below CSS properties</p><pre>div {<br>width: 4rem;<br>height: 4rem;<br>background: yellow;<br>}</pre><pre>.<em>rose</em> {<br>background: red;<br>}</pre><pre>.<em>dark</em> {<br>background: black;<br>}</pre><p>open your App.js and import the App.css file(you can ignore this step if you have it imported already)</p><pre>import &#39;./App.css&#39;</pre><p>Now, you can render an empty div element and button element</p><pre>...<br> const App(){<br>  return (<br>      &lt;section&gt;<br>      &lt;div&gt;&lt;/div&gt;<br>      &lt;button&gt;Change Color&lt;/button&gt;<br>      &lt;/section&gt;<br>  )<br>}</pre><pre> export default App;</pre><h3>Adding Local State</h3><p>At this point, we will add a local state to the <em>App</em> component using a hook called <a href="https://reactjs.org/docs/hooks-state.html">useState</a>-this returns an array with the value we need and a function to change it.</p><pre>...<br>const App(){<br>  const[color, setColor] = useState(&#39;&#39;);</pre><pre>return(</pre><pre> &lt;section&gt;</pre><pre>&lt;div className={color}&gt;&lt;/div&gt;</pre><pre>...<br>)</pre><pre>export default App;</pre><p>we have successfully added a local state to the app component and give our div element a class name from the state, with this any time we update the state via the setColor function the div element also re-renders.</p><p><em>let’s try it!</em></p><p>First, we will add an onclick event to the button element</p><pre>...<br> &lt;button onClick={() =&gt; setColor(&#39;rose&#39;)}&gt; change color &lt;/button&gt;<br>...</pre><p><em>i think we did it!</em></p><p>try clicking the button and watch the background color of the div change from yellow to red.</p><p>Thanks for reading this article, I hope you learned something cool today on React and dynamic styling.</p><p>You can follow me on <a href="https://twitter.com/AI_Lift">Twitter</a>, <a href="https://github.com/armstrong99">Github</a>, and <a href="https://www.linkedin.com/in/ndukwearmstrong/">Linkedin</a>, have a lovely day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f7258d29cd0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/dynamic-styling-with-reactjs-7f7258d29cd0">Dynamic Styling With ReactJS</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Styling In Vanilla JS]]></title>
            <link>https://blog.devgenius.io/dynamic-styling-in-vanilla-js-bcf68b55582a?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf68b55582a</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[styling]]></category>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Thu, 22 Apr 2021 22:16:27 GMT</pubDate>
            <atom:updated>2021-04-23T07:26:54.346Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*fM2DnWysZ9l_RydLyu2o_Q.png" /><figcaption>vanilla JS</figcaption></figure><p>Styling is a very useful concept in front-end development, one way to achieve this is by assigning class names and id’s to HTML tags and giving them some CSS properties in an external stylesheet.</p><p>In real-world scenarios of web development, the properties of elements may need to be changed dynamically, a good example is the dark and light themes you see on web pages.</p><h3>How Dynamic Styling Works</h3><p>Dynamic styling is changing the CSS properties of the DOM elements without manually doing so. And one way we achieve this is by using JavaScript.</p><p>With Javascript, we can dynamically change the class names, id’s and any other attribute of DOM elements</p><p><em>let’s code!</em></p><p>Create a folder <em>dynamicstyle </em>and add the following files</p><p>a. index.html</p><p>b. index.css</p><p>c. index.js</p><p>In the index.html, make an empty div element and a button element</p><pre>...<br> &lt;div&gt;&lt;/div&gt;<br>&lt;button&gt;Change Color&lt;/button&gt;<br>...</pre><p>don&#39;t forget to also link your CSS file using:</p><pre>&lt;link href=&quot;index.css&quot; rel=&quot;stylesheet&quot; /&gt;</pre><p>In the index.css file create class name’s with defined properties that we would dynamically add to the dom elements(for this case is the div tag).</p><pre>div {<br>width: 4rem;<br>height: 4rem;<br>background: yellow;<br>}</pre><pre>.<em>rose</em> {<br>background: red;<br>}</pre><pre>.<em>dark</em> {<br>background: black;<br>}</pre><p>We gave the div some initial CSS properties of the background color of yellow and equal widths and heights of 4rem.</p><h3>Dynamic Styling With Javascript</h3><p>At this point link your index.js file to the HTML file using the script tag at the bottom of the HTML file as shown below</p><pre>...<br>&lt;script src=&quot;index.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In the Javascript file now add the below codes to change the background color when the button is clicked once and double-clicked</p><pre>let<em> </em>htmlDiv<em> </em>=<em> document.getElementsByTagName</em>(&#39;div&#39;)[0]</pre><pre>let<em> </em>htmlBtn<em> </em>=<em> document.getElementsByTagName</em>(&#39;button&#39;)[0]</pre><pre><em>htmlBtn.addEventListener</em>(&#39;click&#39;, function() {</pre><pre><em>htmlDiv.classList.add</em>(&#39;rose&#39;)</pre><pre>})</pre><pre><em>htmlBtn.addEventListener</em>(&#39;dblclick&#39;, function() {</pre><pre><em>htmlDiv.classList.add</em>(&#39;dark&#39;)</pre><pre><em>console.log</em>(&#39;dbl&#39;)</pre><pre>})</pre><p>We got the button and div elements by their tag names and assign them to variables <em>htmlBtn</em> and <em>htmlDiv</em>, and then added an event listener to listen to when the button is clicked once and double-clicked.</p><p>Also using the classList feature, we can add classes to the div element, and this way dynamically changing the CSS properties.</p><p><em>congratulations!</em></p><p>There are a lot of things you can build and do now with what you have, I will encourage you to read <a href="https://www.w3schools.com/jsref/prop_element_classlist.asp">more</a>, and also follow me on <a href="https://twitter.com/AI_Lift">Twitter</a>, <a href="https://www.linkedin.com/in/ndukwearmstrong/">Linkedin, </a>and <a href="https://github.com/armstrong99">Github</a></p><p>Thanks for reading, have a lovely day ahead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf68b55582a" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/dynamic-styling-in-vanilla-js-bcf68b55582a">Dynamic Styling In Vanilla JS</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using styled-components and Props With Typescript React]]></title>
            <link>https://blog.devgenius.io/using-styled-components-and-props-with-typescript-react-a3c32a496f47?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3c32a496f47</guid>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[styled-components]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Thu, 22 Apr 2021 21:05:58 GMT</pubDate>
            <atom:updated>2021-04-23T07:26:52.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e50ASOBklHRmrnuybi9mtA.png" /></figure><p>Styling and building a sleek user interface or UI is a fundamental process in front-end development. One of the fast, high-performance and easy-to-use styling libraries is the <a href="https://styled-components.com/">styled-components</a>.</p><p>Typescript is an awesome programming language built on javascript, although much code might be written for a similar task in javascript the advantages worths it.</p><h3>Type Checking</h3><p>Typescript is a strictly typed language and just like Java, C++, C#, etc she ensures you set a type for every variable, function, and function argument.</p><pre>let num: number = 12;<br>const myFunc = (name: string):string =&gt; name + &#39;john&#39;;</pre><p>This is a basic rule of Typescript and you can read more about it from her <a href="https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html">docs</a></p><h3>Create React App</h3><p>We will begin firstly by creating a typescript-enabled react app, if you already have one you can skip this step.</p><p>Open your terminal and run the below command</p><pre>npx create-react-app my-app --template typescript</pre><pre># or</pre><pre>yarn create react-app my-app --template typescript</pre><p>This will create a basic template like the one below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*M-EHwOGXCLCthHpntkk0Sw.png" /><figcaption>typescript react</figcaption></figure><p>Next, You install styled-components and the type definitions by running the below commands at your root directory</p><pre>npm i styled-components @types/styled-components</pre><pre>#or</pre><pre>yarn add styled-components @types/styled-components</pre><h3>Developing A Button Element</h3><p>Open your App.tsx or App.ts file and import the styled-components package</p><pre>import styled from &#39;styled-components&#39;</pre><p>Above the App function, create a styled button element and render it inside a HTML section tag</p><pre>const BUTTON = styled.button`<br>  border: 1px dotted yellow;<br>  background: white;<br>  color: black;<br>  font-weight: 500;</pre><pre>`</pre><pre>const App(){<br>return (<br>   &lt;section&gt;<br>  &lt;BUTTON&gt; First Btn &lt;/BUTTON&gt;<br>  &lt;BUTTON&gt; Second Btn &lt;/BUTTON&gt;</pre><pre>   &lt;/section&gt;</pre><pre>)</pre><pre>}</pre><h3>Passing Props To Component</h3><p>Properties or props for short, are used to make UI components more dynamic, consider you need two buttons with a different border-color but other CSS properties are the same, you can pass props to each button, with some set of conditions that if that props value is available it should change the CSS property.</p><p><em>let’s do this!</em></p><pre>...</pre><pre>  &lt;BUTTON submit={true}&gt; first Btn &lt;/BUTTON&gt;<br>  &lt;BUTTON pay=&quot;shopping&quot;&gt; Second Btn &lt;/BUTTON&gt;</pre><pre>...</pre><p>From the code snippet above I gave the first button a prop of <em>submit </em>and the data type is a <em>boolean</em>, for the second button I gave it a prop of <em>pay </em>and the data type is a <em>string</em>.</p><p>Now, I define an interface at the top of the styled button with both properties</p><pre>...<br> interface IBtn {</pre><pre>  submit: boolean,<br>  pay: string</pre><pre>}</pre><pre>const BUTTON = styled.button`<br>  border: 1px dotted yellow;<br>  background: white;<br>  color: black;<br>  font-weight: 500;<br> `<br>...</pre><p>Now, you simply pass this interface to the styled button, this helps typescript to check the types of pros to be received for the component</p><pre>...<br>const BUTTON = styled.button&lt;IBtn&gt;`<br>...</pre><p><em>simple! right?</em></p><p>And then we can define the CSS properties based on the props the component receive without typescript throwing any error</p><pre>...<br>const BUTTON = styled.button&lt;IBtn&gt;`<br>  border: 1px ${props =&gt; props.submit ? &#39;solid&#39; : &#39;dotted&#39;} yellow;<br>  background: white;<br>  color: black;<br>  font-weight: ${props =&gt; props.pay === &quot;shopping&quot; ? &#39;bold&#39; : 500};<br>`<br>...</pre><p><em>congratulations!</em></p><p>You made this far in safely passing props to styled components without typescript yelling at you. I know you might be wondering why I use an <em>interface</em> instead of a <em>type</em>, well you can read more about that from this <a href="https://blog.logrocket.com/types-vs-interfaces-in-typescript/">article</a>.</p><p>Thanks for reading this article, you can follow me on <a href="https://twitter.com/AI_Lift">Twitter</a>, <a href="https://github.com/armstrong99">Github</a>, and <a href="https://www.linkedin.com/in/ndukwearmstrong/">Linkedin</a>, have a lovely day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3c32a496f47" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/using-styled-components-and-props-with-typescript-react-a3c32a496f47">Using styled-components and Props With Typescript React</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Images To DockerHub With CircleCI]]></title>
            <link>https://blog.devgenius.io/deploy-images-to-dockerhub-with-circleci-3f5b716cfe1e?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f5b716cfe1e</guid>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Mon, 05 Apr 2021 10:20:43 GMT</pubDate>
            <atom:updated>2021-04-05T21:26:48.667Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*z-iALiU8xDV_FI4YAwxmZA.png" /></figure><p>containers, images, cloud, docker, Kubernetes, etc. are all common terms we hear from DevOps engineers and senior backend engineers or cloud architects. Building apps or servers are very good but more importantly is the hosting, deployment, maintenance, and scaling of them.</p><p><a href="https://circleci.com/docs/2.0/about-circleci/">CirclCI </a>enables engineering teams with automation for your software builds, tests, and deployments.</p><p>Docker is a light-weight OS-level virtualization tool that enables us to deliver softwares in packages called containers.</p><p>Building your containers locally on your OS can take a bit of time depending on how sophisticated your system is and sometimes may not be able to run docker. Also, manually building and pushing containerized apps to <a href="http://hub.docker.com/">docker-hub</a> can be stressful or not a best practice.<br>You can automate this process, using GitHub and CircleCi.</p><p>For this project, I will develop a simple express server and build a docker image for it and push it to the docker hub using circleci.</p><p>Before you further read ensure you have an account with github, circleci, and docker hub.</p><h4>Project Setup</h4><p>Open your github and create a public repo, let’s call it *my-first-dockerhub*, you can now clone this project on your preferred editor.</p><p>create the following files in your root directory — index.js Dockerfile .dockerignore .gitignore</p><blockquote>touch index.js Dockerfile .dockerignore .gitignore</blockquote><p>inside your index.js file add the below codes</p><pre><br>require(“dotenv”);<br>const express = require(“express”);</pre><pre>const app = express();</pre><pre>const { log } = console;</pre><pre>app.get(“/user”, (req, res) =&gt; {<br> res.send({<br> result: [<br> {<br> name: “armstrong”,<br> status: “developer”,<br> },<br> ],<br> });<br>});</pre><pre>const port = process.env.PORT || 5000;</pre><pre>app.listen(port, () =&gt; log(`Server running on port ${port} 🔥`));</pre><h4>Setup For Docker</h4><p>The magic to make your app a docker image is actually done inside the *Dockerfile* you just created.</p><p>Add the following code inside the Dockerfile:</p><pre><br>FROM node:14</pre><pre>WORKDIR /project</pre><pre>COPY package*.json ./</pre><pre>RUN npm ci</pre><pre>COPY . .</pre><pre>EXPOSE 8081</pre><pre>CMD [“node”, “index.js”]</pre><p>*FROM node:14* talks about the environment we want to run our app on, of course is a node app, so we choose node version 14</p><p>You can read more about the meaning of the other statements on the nodejs officially <a href="https://nodejs.org/en/docs/guides/nodejs-docker-webapp/">docs</a></p><p>With this, our app dependencies will be installed via the RUN command and running on port 8081 in the docker container</p><h4>Setup For Circleci</h4><p>This is the most interesting part of this article for me. The next thing after the previous step is to build your docker image, using the command -<br><br> docker build <br> <br>Now instead of doing this with our local OS, we will employ the rich infrastructure of circleci.</p><h4>Connect Git Repo To Circleci</h4><p>Open your circleci dashboard, look for your github repo and click on the button *set up project* , this may ask you for a *.circleci* directory, you can ignore it for now.</p><h4>Circleci Configuration</h4><p>In your root directory create a new directory — *.circleci*, inside the directory create a file *config.yml*</p><pre><br>touch .circleci/config.yml<br></pre><p>inside the config.yml, add the below codes</p><pre><br>orbs:<br> docker: circleci/docker@1.5.0<br>version: 2.1<br>executors:<br> docker-publisher: <br> environment:<br> IMAGE_NAME: ndukwearm19docker/docker-node-app<br> docker: # Each job requires specifying an executor<br> # (either docker, macos, or machine), see<br> — image: circleci/node:latest<br> auth:<br> username: $DOCKERHUB_USERNAME<br> password: $DOCKERHUB_PASSWORD</pre><pre>jobs:<br> publishLatestToHub: <br> executor: docker-publisher<br> <br> steps: <br> — checkout<br> — setup_remote_docker<br> — run: <br> name: Publish Docker Image to Docker Hub<br> command: |<br> echo “$DOCKERHUB_PASSWORD” | docker login -u “$DOCKERHUB_USERNAME” — password-stdin<br> docker build -t $IMAGE_NAME .<br> docker push $IMAGE_NAME:latest<br>workflows:<br> version: 2<br> build-master:<br> jobs:<br> — publishLatestToHub<br><br>The config.yml is the magic that tells circleci what to do with our app, for this demo we want it to build a docker image.<br>In circleci *workflows* are simply orchestrators, they order how things should be done, *executors* defines or groups up task, *jobs* define the basic steps and commands to run.</pre><p>So I have a workflow called *build-master* and does a job *publishLatestToHub* it start by running an executor called *docker-publisher* which sets an environment variable called IMAGE_NAME and runs a docker environment that should run the latest version of node.</p><p>The next lines of code are the</p><ul><li>checkout — this asks circleci to view our repository or take account of the entire directories and files we have on the repo,</li><li>setup_remote_docker — this tells docker to build the image on an isolated docker environment, read more <a href="https://circleci.com/docs/2.0/building-docker-images/">here</a>,</li><li>run — the run command is just like your regular cmd or shell, so here type the docker commands to build your image and push to docker hub.</li></ul><pre><br> echo “$DOCKERHUB_PASSWORD” | docker login -u “$DOCKERHUB_USERNAME” — password-stdin<br> docker build -t $IMAGE_NAME .<br> docker push $IMAGE_NAME:latest</pre><p>DOCKERHUB_PASSWORD and DOCKERHUB_USERNAME should be set as an environmental variable in your circleci dashboard for this project, read more <a href="https://circleci.com/docs/2.0/env-vars/">here</a></p><h4>Finally!</h4><p>You can now commit and push to github, go back to your circleci dashboard, and watch your image pushed to docker hub.</p><p>Thanks for taking the time to read through, watch out for more of my article, you can follow me on <a href="https://twitter.com/AI_Lift">Twitter</a>, invite me on your next project on <a href="https://www.linkedin.com/in/ndukwearmstrong/">LinkedIn</a>.</p><p>Remember to keep coding, reading, and live rightly.</p><p><a href="https://github.com/armstrong99/circleci-docker-CICD-pipeline-NodeJS">link to repo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f5b716cfe1e" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/deploy-images-to-dockerhub-with-circleci-3f5b716cfe1e">Deploy Images To DockerHub With CircleCI</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s Simplify React Redux]]></title>
            <link>https://blog.devgenius.io/lets-simplify-react-redux-996fbb52c547?source=rss-4c22c48757a8------2</link>
            <guid isPermaLink="false">https://medium.com/p/996fbb52c547</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Ndukwe Armstrong]]></dc:creator>
            <pubDate>Wed, 23 Sep 2020 09:06:58 GMT</pubDate>
            <atom:updated>2020-09-23T19:10:44.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*cnAeZGWFBFzYaESBi9saoA.jpeg" /><figcaption>React Redux-let’s make it simple</figcaption></figure><p>Most front end Jobs out there in the world today and even your personal projects will always require a robust state manager for the UI, because as the application scales data transfer, data mutation, and control increases.</p><p>The solution to this as you may know is Redux or Mobx-State-Tree(MST). I love functional programming especially when writing front end codes, hence I choose to learn in-depth Redux instead of MST which is more of an OOP(Object-Oriented Programming) style. In this article, I will be simplifying React Redux as complex as it appears to be, just stay chill, read to the end with a cup of coffee and cookies around.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kDgIX4pbXBS_350zYBzLw.jpeg" /><figcaption>Spar Mall for shopping in Nigeria</figcaption></figure><h3>The Concept And Terminologies</h3><p>Imagine yourself visiting a very big mall like the one shown above, you can buy anything you want in here-phones, food, clothes, etc. Instead of having a phone market in location A, a food market in location B, and a clothing market in location C, hurray!!! with a shopping mall, you have all the market types in one place.</p><p>This works the same with your UI, instead of each component managing its own state as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*v2WElOc9uFZS3uJTgAH9nw.jpeg" /><figcaption>Stateless Functional Components — ReactJS</figcaption></figure><p>we now have a mall or store called REDUX STORE where all the states(clothe market, food market, and phone market component) or data of each component are kept and can be retrieved or updated anytime from anywhere, awesome!!! so component A(phone market) is now in a store or mall, and if I need a phone I just drive to the Mall, no need to pass props to component A(phone market) to get phones, same applies to all other components.</p><p>This makes your app components free from logic, lightweight as they only consume data and don&#39;t manage state at all, super dynamic as they only need to drive to the mall or redux store to get anything they need.</p><h4>REDUCERS</h4><p>Since we now have a big mall or redux store, we still need sales workers to handle each segment of the mall. In Redux these sales workers handling each segment of the mall or store are called REDUCERS, they take your request and give you a response e.g</p><p>ME: I need an iPhone 5</p><p>Sales Worker: Hi, I am John, I deal on iPhones, what color do you need sir?</p><h4>ACTION</h4><p>Going to a mall, I will make a request for the item I need either verbally or written. In Redux the request you are making containing your title or type and a brief description is called the ACTION or ACTION payload(which is a plain javascript object)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*GGc6cRTnZySrxtXcCM7OMw.jpeg" /><figcaption>Redux Actions</figcaption></figure><h4>DISPATCH</h4><p>Dispatchers or Dispatch is just the way(a method or function) we send our action or payload to the store, And once It arrives at the store, the Reducer that handles GET_PHONE action type now continues with the transaction process of getting the phone from the store</p><h4>CONNECT</h4><p>CONNECT is another simple term to understand, for a buyer(a component that needs data) to get an item from the mall, I have to drive my car to the mall. The car or driving process to the mall is called CONNECT in React-Redux. it&#39;s just a way of getting information from the store or sending actions or payload to the store. so with CONNECT I can get something from the store and also dispatch an action.</p><h3>LET’S BUILD OUR REACT REDUX SHOE SALES APPLICATION</h3><p>For this application, we will be working with a react app, so open your cmd and create one</p><p><em>npx create-react-app shoesshop</em></p><p>learn more here:<a href="https://reactjs.org/docs/create-a-new-react-app.html"> react app</a></p><p>if you have done that install the below dependencies</p><p><em>npm install redux react-redux redux-thunk redux-devtools-extension or yarn add redux react-redux redux-thunk redux-devtools-extension</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*GFDzXzsLluyij9mCfV1mog.jpeg" /><figcaption>You should have a similar Directory</figcaption></figure><p>Inside the src folder create the below folder:</p><ol><li>component folder: This folder houses all of our components. create the AddShoes.jsx, ViewShoes.jsx, EditShoes.jsx</li><li>container folder: This folder houses all of our containers. create the Ad.jsx, ViewShoesCont.js, EditShoesCont.js.</li></ol><p><strong>CONTAINERS:</strong> Imagine for a second a pregnant woman, she does all the eating, walking, and medication while the baby just takes the results of her vitals. In React Redux containers(pregnant mothers) are wrappers around components, they interact with the store, get all the data, and even dispatch actions and then render and pass the result as props to components. This best practice helps keep your component lightweight and free from logic.</p><p>3. Actions folder: This folder houses all of our actions or action creators.</p><p><strong>ACTION CREATORS:</strong> Actions creators are plain javascript function that returns an action</p><p>4. Reducer folder: This folder houses all of our redux reducers.</p><p><strong>REDUCERS(technical definition):</strong> Are Javascript functions that take the PREVIOUS state of the application and also the ACTION and returns a new or next state. Hence, they are pure functions.</p><p>5. Pages Folder: This folder houses all of our Pages. create a Home.jsx, Sales.jsx, dashboard.jsx file inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*6PZb-f3anprkcX5drZixuQ.jpeg" /><figcaption>Our File Structure</figcaption></figure><h4>INTEGRATING REDUX TO REACT APP</h4><p>In the Reducer Folder add rootReducer.js and shoeReducer.js file.</p><p>The application we are building needs only one reducer(sales worker in our mall), she(shoeReducer) handles all transactions that have to do with shoes.</p><p>So if you are building an app that has more than one concept, you will need more reducers to handle each of them. I hope to build such an app in my next article on handling Async/Sync Operations in React-Redux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*oXjYsvfWt6kieAQdZRJ7yA.jpeg" /></figure><p>in<em> rootReducer.js add the below code</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*RakSWyReUm--0nZ5foynEw.jpeg" /></figure><p>first, we imported our <em>shoeReducer </em>and then we import <em>combineReducer</em> from <em>redux. with combineReducers </em>we can keep all our app reducers in a unified way. it accepts an object(key-value pairs), so in the mall(redux store) our <em>shoeReducers </em>is identified with <em>shoesStore </em>as shown above</p><p>in <em>shoeReducer.js</em> add the below code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*1BsG_YpULita_q9N7Yujiw.jpeg" /></figure><p>Remember, reducers in redux are pure javascript functions. Its first parameter is the state and the other is the action object.</p><p>in redux the state must be immutable, so you don&#39;t ever do <em>state.name, state[0].user.country, </em>you only return a new or next state using methods like filter, map, spread syntax(…), etc which don&#39;t tamper with the original array but return a new one.</p><p>in the root directory in<em> index.js</em> import the following modules</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*JkaKGzyETqleUIhahE67Bg.jpeg" /></figure><p><strong><em>redux:</em></strong> we import <em>createStore</em>, which enables us to actually create the store, so see it as a civil engineer in redux. <em>applyMiddleware</em> is a wrapper that enables us to make API calls with redux</p><p><strong><em>rootReducer:</em></strong> we import our rootReducer.js file we created above</p><p><strong><em>thunk:</em></strong> thunk helps us in making an API call, is just a middleware that makes that possible</p><p><strong><em>provider:</em></strong> provider, just like in React Context API, makes available the data in our store to every component in the application</p><p><strong><em>composewithdevtools:</em></strong> this helps us to use visualize our redux store in the browser using her <a href="https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en">browser extension</a></p><p>Now, we use our imported functions to actually create the store and wrap our root component(App.js) with <strong><em>Provider</em></strong></p><p>add the below codes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*RlaCk_nLNwdh9WRt7yzP5w.jpeg" /></figure><p>A variable store then assigned to <em>createStore</em>, accepting first our rootReducer and <em>composewithdevtools </em>wrapping our <em>thunk </em>middleware</p><h3>CONCLUSION</h3><p>This is not the end of the tutorial just the beginning, Redux is always a large topic to cover in-depth from scratch in one article. In my next article Visualising React-Redux store in Browser, I will be completing this application and also show you how to visualize the store in your browser.</p><p>Article repo: <a href="https://github.com/armstrong99/Simplifying-React-Redux">https://github.com/armstrong99/Simplifying-React-Redux</a></p><p>Thank you so much for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=996fbb52c547" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/lets-simplify-react-redux-996fbb52c547">Let’s Simplify React Redux</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>