<?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 Gilbert Mpanga on Medium]]></title>
        <description><![CDATA[Stories by Gilbert Mpanga on Medium]]></description>
        <link>https://medium.com/@gilbertmpanga.gm?source=rss-12af8e32f9e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QwgpuUdXvoEivm25</url>
            <title>Stories by Gilbert Mpanga on Medium</title>
            <link>https://medium.com/@gilbertmpanga.gm?source=rss-12af8e32f9e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:53:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gilbertmpanga.gm/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[How to deploy streamlit on Azure?]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/how-to-deploy-streamlit-on-azure-e4e40272c2d6?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e40272c2d6</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 22:08:01 GMT</pubDate>
            <atom:updated>2024-05-07T08:47:41.219Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to deploy streamlit on Azure without docker?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qe1Fr_sbXchQB7hU" /><figcaption>Photo by <a href="https://unsplash.com/@ventiviews?utm_source=medium&amp;utm_medium=referral">Venti Views</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Streamlit is such an awesome framework for quickly spinning up dashboards, data and visualisation apps . It took me about just about 5 hours to get something up and running, Crazy!</p><p>So how do you get the same speed with deployment? Well at first I had built a data intensive app and deployed using <a href="http://render.com/">render.com</a> compute pro plan for $25, but I ran out of memory so fast. So I decided to explore a couple of options and landed on Microsoft Azure App Service.</p><p>Majority of tutorials on deploying streamlit with App Service cover deployment using docker. It ain’t bad but the steps are quite long. In this article am going to cover how I deployed streamlit with just a single command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s7cKo1dAgQzjHH5o3BOMdw.png" /></figure><pre>az webapp up --name &quot;&lt;app-name&gt;&quot;  --runtime &quot;PYTHON|3.11&quot; --resource-group &quot;&lt;resource-name&gt;&quot; --sku &lt;pricing-plan&gt; --logs  --location &quot;region”<br></pre><p>Step 1.</p><p>Inside your python project, make sure you save your main entry file as <strong>app.py </strong>or <strong>application.py</strong>. Make sure you have you save the necessary pip dependencies by running <strong><em>pip freeze &gt; requirements.txt</em></strong></p><p>step 2.</p><p>Create your azure webapp service by running the command below. I will explain briefly why included the above flags and each means:</p><pre>az webapp up --name &quot;&lt;app-name&gt;&quot;  --runtime &quot;PYTHON|3.11&quot; --resource-group &quot;&lt;resource-name&gt;&quot; --sku &lt;pricing-plan&gt; --logs  --location &quot;region”</pre><p>— name : name of your application<br> — runtime: the python version of runtime. You can create run this small script inside your application to check python runtime version.</p><pre>import sys<br>print(&quot;Python version: &quot; + sys.version)</pre><p>Mine for this case was 3.11, which I used following the convention “PYTHON|3.11” . You can run the above command to see what operating system versions are supported.</p><pre>az webapp list-runtimes --os linux --output table</pre><p>— resource-group: the name of your resource group. You can head over the console to create it .<br> — sku: the pricing plan you’re interested. Visit <a href="https://azure.microsoft.com/en-us/pricing/details/app-service/linux/">pricing</a> and copy the sku for example for free plan by default it’s B1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EnoAnywE7VDrk3yimDR3Jw.png" /></figure><p>— logs: it’s for enabling logs for debugging purposes.<br> — location: for setting region where you want to serve from. You can run the above command to list region names you’re interested in or visit the supported regions from azure regions page.</p><pre>az webapp list-runtimes --os linux --output table</pre><h3>Configure custom start command:</h3><p>The a<strong>z webapp up</strong> command behind the scenes runs off a docker container and so it’ll use default flask or django commands to run the app, which we don’t want. So head over the console and specify your own command to run the app , we also want to make sure that the streamlit app runs on port 80 so that’s exposed.</p><p>Look up App services from the search bar &gt; your service name &gt; configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcf6W1WbO3e4b8qKtpptDQ.png" /></figure><p><strong>Add this command:</strong></p><pre>streamlit run app.py --server.port 8080</pre><p>Also make sure you add these environment variables under Application settings.</p><p>WEBSITED_PORT: 80<br>port: 8080</p><p>Optional: If you want automatic CI/CD, you can link your project to github by navigating to deployment center in the app service and connect your github.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bVAP25VKMIm6uPQiLDTCfw.png" /></figure><p>Great! Refresh and redeploy by re-runing 🔥. Voila! your app is now live:</p><pre>az webapp up --name &quot;&lt;app-name&gt;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fsPrGj9h6pG3uRVz-aL1UQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4e40272c2d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How do I accept payments when Stripe or Paypal isn’t supported in my region?]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/how-do-i-accept-payments-when-stripe-or-paypal-isnt-supported-in-my-region-76ff68799831?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/76ff68799831</guid>
            <category><![CDATA[stripe]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[indiehackers]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Sat, 29 Jul 2023 11:38:02 GMT</pubDate>
            <atom:updated>2023-07-29T11:38:02.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8rMoaWSOaXW4QTs-" /><figcaption>Photo by <a href="https://unsplash.com/@towfiqu999999?utm_source=medium&amp;utm_medium=referral">Towfiqu barbhuiya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So you want to create a global tech startup or easily charge customers from the United States or Europe and Australia but then you discover the bad news, only a handful of countries are supported . If you’re lucky you’re on this list awesome! 🎊 , you can skip the rest of the section and sign up at <a href="https://app.firstbase.io/">FirstBase HQ</a>.</p><p>If you’re aren’t lucky, then lets proceed!</p><p>Below is the list of supported countries by <a href="http://stripe.com/">Stripe</a>. Note, I’ve left out other payment processors since they too follow this category. Stripe is the easiest, and most popular payment processor to use on the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ckts8cKRoaxblhh90D3qKQ.png" /></figure><p>Yikes, these are too few! Another best alternative would be <a href="https://paddle.com/">Paddle</a>. But it has many caveats, it comes with a fixed pricing prices are predetermined(let’s say you wanted to charge users $5, this isn’t allowed), and worst case of all, they charge a hefty 5% + 50 cents fee and only a handful of business categories are supported. Some countries again aren’t supported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DMIuMPmKT9hXTy_lnL5Mkw.png" /></figure><h3>The solution? Incorporate an LLC in the United States in the cheapest state.</h3><p>First of all why even incorporate an LLC? An LLC is a Limited Liability Company, it’s a small registered entity great for small businesses starting out, they offer low tax benefits and easy to maintain</p><p>I got introduced to FirstBase while I was in YC startup school. It enables small businesses and startups to easily register LLCs in Wyoming, it has no income state tax , and the best part? The starting registration year, FirstBase care for you everything, including filing of the first Wyoming Annual Business Report fee for free. You only pay a one time fee of $300 and FirstBase HQ takes care for you everything , processing all documents i.e company Employee Identity Number (EIN), certificate of incorporation etc and the great part it works with <strong>Stripe</strong>!</p><p>Now let me walk you through how the process works!</p><h3>What’s the process like when incorporating an LLC?</h3><ol><li>Sign up via email</li><li>Once you’re inside the dashboard, it’s an easy 3 step process, You’ll be prompted what kind of entity you’d like to create an LLC or C-corp. We’ll go with LLC. C-corps are great if you’re looking to raise money from investors and require lots of money to start and maintain.</li><li>Next, you’ll be promoted for your a few documents like national ID, number of share holder / founder percentage percentage ownership in the business. You can pick any or choose 100% if you’re only one founder</li><li>Finally, once finished you’ll be asked to pay $300 and voila! It takes about there 3–7 business days to process documents, FirstBaseHQ will periodically send you emails of each stage for example you can receive your EIN in the first 2 days and so forth.</li></ol><p>Once the entire process is completed, you’ll receive all your company formation details i.e EIN (Employee Identity Number), Form 8821 form, <br>LaserEyes LLC Articles of Organisation, LaserEyes LLC Resignation of Organiser , LaserEyes LLC Resolution to Open a Bank Account etc</p><p>You’ll also receive details of your physical address you’ll use this through out your business operations.</p><p>Another important thing you’ll need is a US phone number, FirstBaseHQ does not provide one but you can create one using <a href="https://openph.one/referral/WuoSNBq">OpenPhone</a>. It’s the best value for money and cheaper.</p><h3>How much will it cost you to run your LLC?</h3><p>All businesses in the United States are required to file taxes once a year to the IRS , this happens every April 15th of any year. If your business hasn’t made any money, you can file $0 returns (it’s always important to file, even if you haven’t made any sales). You can hire best and cheap accountants from F<a href="http://fiverr.com/">iverr</a> to process tax documents for you. Or if you’re confident and know about the IRS system , you can download the tax from forms directly from IRS website</p><p>Other costs? The state of Wyoming requires businesses to file $60 Annual Business Report (If your business has less than $25,0000 in assets) once of July every year.</p><p>That’s all! You can get 10% discount off by signing up here with my coupon code <strong>STARTGILBERTXURF8C7D4 </strong>using <a href="http://firstbase.io/">FirstBase</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76ff68799831" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t know what to write about?]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/dont-know-what-to-write-about-11147aaa2fb?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/11147aaa2fb</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Wed, 19 Apr 2023 06:03:32 GMT</pubDate>
            <atom:updated>2023-04-19T06:03:32.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cYeLMt8is2rl_-d3" /><figcaption>Photo by <a href="https://unsplash.com/@ajing_?utm_source=medium&amp;utm_medium=referral">aj_aaaab</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s been minutes and I’m still staring at my blank white medium page pondering on what to write about. At the height of this confusion, I’m puzzled as to I should focus on, maybe a write up a new story on how am finally conquering my fear and launch a new startup, or be this mighty innovator and highlight my thought process, or simply right about how my day went yesterday when I tried filling $0 taxes for the second time, I mean that would be so super practical and help many.</p><h3>💡 The bulb moment!</h3><p>Forget about what I said earlier, as I continued to write , I saw that most of my patterns on what to express out is simply mimicry to a certain degree. I carefully examined my thoughts for a seconds, I saw there’s an idea of a need to become the most celebrated &amp; prolific writer, all successfully with everyone reading my stuff some like <strong>James Clear, </strong>in other instances I saw my self as a great inventor who had carefully wrote down their thought process and became this great guy everyone admired.</p><p>Arghhh I hate the fact that even the style and art of writing am using to type this is also stolen, not mine. I’m mimicking some styles of writers I’ve been reading from for a quite a long time. Perhaps it some how explains why I initially feel the gas and pumped ready to become the next great guy, only to loose motivation the next day. Holy smokes!!!!!</p><p>So where does that leave me? Should I continue silencing some how a still voice that carries originality in me and never get excited by external influence and follow it deep enough ? Or maybe I should learn from others maybe figure out how they discovered themselves and began pouring out what they have inside to the whole world.</p><p>I’m gonna get back! Time to explore⚡️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11147aaa2fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can chatGPT help you reduce development time?]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/can-chatgpt-help-you-reduce-development-time-43f25bf81f2e?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/43f25bf81f2e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 19:44:13 GMT</pubDate>
            <atom:updated>2023-03-29T09:21:20.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sLaU-6E07s62JGve" /><figcaption>Photo by <a href="https://unsplash.com/@aronvisuals?utm_source=medium&amp;utm_medium=referral">Aron Visuals</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I get it everyone in the dev community is screaming on how ChatGPT is going to replace us, lots of fancy demos generating apps on the fly and we are amazed, while for others it’s causing an existential crisis. Just take a look at this guy from Hacker News. Yikes!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MwsA_Uvd_m69eiUAKaM2XQ.png" /></figure><p>I know it’s scary, I’ve been amazed by the results it throws out during my work. I’ve used it to generate regex, refactor code, generate new components and work step by step to finish the code and it really cuts the time to develop in shot.</p><p>I understand many are so fixated and terrified by the possibility of ChatGPT replacing them. But we are missing the full picture. Honestly what I hated about software, is getting to repeat the same logic, code for components all over the again, most times we just copy and paste stuff from Stack Overflow, old projects then piece them together to create a product. Most projects I’ve discovered, 90% of them is reusing old solved solutions, then 10% accounts for logic, and new problems that may arise.</p><p>Most limitations of Chat GPT have already been mentioned by many Youtube videos and blogs, so I won’t go through them. But one thing I see that’s normally missed, <strong>Time to deliver or Cost of delivery or Time it’ll take to complete an app / website.</strong></p><p>Let’s face it, every developer sucks at estimates. No one ever gets estimates right, millions of dollars get wasted in delayed projects, it kills so many businesses. Can ChatGPT reduce the time to deliver and act as your pair programmer that not only stops at autocompleting stuff and actually deliver full value , maybe develop the 90% overall and leave the rest to the developer?</p><p>Now that will be the ultimate saviour. If Chat GPT can do for me 90% work and the rest 10% done by me debugging. Why not start an automated dev shop and make thousands of apps and I just chill at the beach in Bahamas while making millions 🤑. Now that would be a dream startup, haha.</p><p>So far that’s impossible, there are lots of limitations one will ever have to overcome, mainly there are token limits so one has to build step by step which pretty sucks, then another thing, there’s no way of combining up all components together to produce an app. Lastly, it’s developer specific, designers can’t work with this, unless they know some CSS and HTML.</p><h3>So what’s next?</h3><p>I’m going to pull out one project I’ve been procrastinating to finish, I’ll experiment and document each component I generated with ChatGPT and see how much time I saved, every component file with a corresponding prompt and then I’ll gauge and see if this tech really speeded up my time. Next if I enjoyed the process, might build a product to address limitations. Just gonna experiment with everything.</p><p>The End!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43f25bf81f2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How should I make work fun?]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/how-should-i-make-work-fun-fb4333fcbef1?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb4333fcbef1</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Thu, 14 Apr 2022 08:23:14 GMT</pubDate>
            <atom:updated>2022-04-14T08:24:24.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hWgZg_4xRjjKnkRW" /><figcaption>Photo by <a href="https://unsplash.com/@lidyanada?utm_source=medium&amp;utm_medium=referral">Lidya Nada</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So who am I? A software engineer. But what’s does a software engineer do?</p><p>Software engineers build stuff off bits and in turn these solve outside real world problems. Hmmm… Sounds pretty fancy and cool. So how can I make my work fun?</p><h4>Background philosophy on the field:</h4><p>I think having some background philosophy , lays a strong foundation on what’s interesting. Questions like, why does this field exist, what can it solve. Also following key contributors maybe Marvin Minsky, Lex Fridman, Alan Turing.</p><h4>What’s your identity in the field?</h4><p>Do I see myself as a craftsman, an entrepreneur, hacker? Well, for my case I think for me builder works well. I admire folks that build products and they get used by many. I mean look at all these messaging apps, one guy’s idea is running the entire world. That’s really so fascinating.</p><h4>Seeing work as a craft</h4><p>Craftsmen have systems and principles on how how they build their things. We call this art. Craftsmen have different styles of art. What’s my style? Well I’m yet to find this out. So far I have discovered a handful of certain techniques from senior devs, but that’s not enough e.g senior devs don’t attack in a waterfall fashion, they attack in a systematic approach e.g divide and conquer. Many times I’ve gotten so frustrated, I attack problems in a build-as-yo-go fashion which is really frustrating and wastes time.</p><h4>Conclusion</h4><p>I could have written lots of other points but I think I just need to perfect on only these 3 areas. Not having motivation to work really sucks. Maybe when I improve, I’ll earn more money and more experience hence will be more motivated. I’m still quite not sure.</p><p>If you have any suggestions you can hit in the comments and let me know, have a lovely Thursday. God bless you 🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb4333fcbef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing this to feel good at my self, Why? Test units are all failing!]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/writing-this-to-feel-good-at-my-self-why-test-units-are-all-failing-b158d7d4342b?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b158d7d4342b</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 11:53:19 GMT</pubDate>
            <atom:updated>2022-02-25T11:53:19.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*1Bm3NxKsHl66cJeRQ0asvA.png" /></figure><p>So over 29 tests are failing I don’t why it’s happening , am all screwed up and the the entire story has been in blocked mode (Jira) for weeks so I’ve ignored it and worked on other tasks.</p><p>Rather than beating up everything and hating myself for being a sloth again. I ain’t gonna buy that crappy cool-aid anymore. Here’s my plan to resolve this:</p><h4># Comment out all failing tests:</h4><p>I’m gonna leave only passing ones , so far when you look at the image i’ve shared above, only 16 ✅ have passed the rest 29 ❌.</p><h4># <strong>Log at least one of the failing</strong></h4><p>Comment one of the failing tests and fix it till it passes.</p><h4># Overall am going to with divide and conquer</h4><p>I know all our tests are too many but what can I do, let me stay patient.</p><h3>Success or not?</h3><p>Well it better works out, whether I like it or not. When am done will finish and publish one of my articles that have stuck in my medium drafts for so long.</p><h3><strong>But why am I writing this?</strong></h3><p>I want to feel better at myself, not trash myself like i’ve always been doing. I’ve had enough of this. I learned this from our pastor last Sunday, he said one of the main reasons why we fail repent &amp; accept Jesus is because we have a guilt consciousness that keeps reminding us how sinful we are, it keeps us in a cycle of self judgement.<strong> <em>In other words, a guilt consciousness is the foundation of all bad habits.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b158d7d4342b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Text strings must be rendered within a <Text> component. ReactNative]]></title>
            <link>https://medium.com/@gilbertmpanga.gm/text-strings-must-be-rendered-within-a-text-component-reactnative-51c1af58b295?source=rss-12af8e32f9e------2</link>
            <guid isPermaLink="false">https://medium.com/p/51c1af58b295</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Gilbert Mpanga]]></dc:creator>
            <pubDate>Tue, 01 Feb 2022 10:34:35 GMT</pubDate>
            <atom:updated>2022-02-01T10:34:35.989Z</atom:updated>
            <content:encoded><![CDATA[<h4>Watch out for this messy bug if you’re new to react native.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PE8fdXXnrbjkx7IJ" /><figcaption>Photo by <a href="https://unsplash.com/@hishahadat?utm_source=medium&amp;utm_medium=referral">Shahadat Rahman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Text should be rendered inside &lt;Text&gt; component:</h3><p>While the error may seem obvious, probably you tried using plain text without wrapping it in a <em>&lt;Text&gt;&lt;/Text&gt;</em> component like so:</p><pre>const myApp = () =&gt; {</pre><pre>return &lt;&gt;hello there!&lt;/&gt; // throws an error❌</pre><pre>};</pre><p>But what if you did every thing right? Let’s go deeper and see how you could shoot yourself in the foot by just this mistake alone.</p><p>You randomly uncomment out commented code and by mistake leave text comment in the component as code. Yikes</p><pre>{/* This is my comment*/}<br>// your other code</pre><p>But after randomly uncommenting:</p><pre>This is my comment<br>/// your other code</pre><p>This is will be executed and an error will be thrown.</p><h3>Second scenario:</h3><p>You have some form of conditional rendering for example a list component of contacts that shows empty state and state with all contacts.</p><pre>const const myContacts = () =&gt; {<br>return (<br>&lt;&gt;<br>{<br> contacts?.length &amp;&amp; &lt;MyListComponent/&gt;<br>}&lt;/&gt;)<br>};</pre><p>As much as it logically looks okay i.e`<em>0 &amp;&amp; &lt;some truthy condition&gt;</em>` returns false. But what if your contacts list at first is undefined or null? This expression will be evaluated to null and cause the entire application to break.</p><h3>Empty string scenario:</h3><p>Let’s say one of your variables you’re trying to use for conditional rendering evaluates to an empty state. Guess what will happen?</p><pre>{<br>emptyStateWithEmptyString &amp;&amp; &lt;MyContactList/&gt;<br> }</pre><p>An the same error will be thrown because any comparison of and operator with strings evaluates to a string.</p><h3>The correct way / Solution:</h3><p>Use ternary condition expressions or use a bang-bang operator to negate or make expression positive.</p><p>For conditional expressions that involve &amp;&amp;. Use ! for falsey expressions and !! (bang-bang) for positive expressions. The example below shows how to evaluate negative and positive expressions respectively.</p><pre>const const myContacts = () =&gt; {<br>return (<br>&lt;&gt;<br>{<br> !contacts?.length &amp;&amp; &lt;MyListComponent/&gt;<br>}</pre><pre>{<br> !!contacts?.length &amp;&amp; &lt;MyListComponent/&gt;<br>}<br>&lt;/&gt;)<br>};</pre><p>The other way is to use a ternary operator to conditionally render your component. We’ll use the same component as previous examples, just with a little bit of refactoring.</p><pre>const const myContacts = () =&gt; {<br>return (<br>&lt;&gt;<br>{<br> contacts?.length ? &lt;MyListComponent/&gt;: null<br>}<br>&lt;/&gt;)<br>};</pre><h4>Final words</h4><p>I hope this helped, I joined a startup a 3 months back to pay the bills but I also run my own startups as indieHacker. Working with big startups has exposed to cool new stuff CI/CD, tests, and remote collaboration in general. However, I realised my break-things mentality won’t help me as the startup I work for demands real production ready stuff. So I’ve decided to document everything about the tech stack in short articles. My mission is to use writing to re-enforce what I’ve learned, and learn enough to be dangerous 😂 so that I finish my day job tasks so that I can focus on my startup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51c1af58b295" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>