<?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 Ambrose Liew on Medium]]></title>
        <description><![CDATA[Stories by Ambrose Liew on Medium]]></description>
        <link>https://medium.com/@ambroseliew1998?source=rss-2d185d8447d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Foi5VxpxFTVP1G75sIpKxw.jpeg</url>
            <title>Stories by Ambrose Liew on Medium</title>
            <link>https://medium.com/@ambroseliew1998?source=rss-2d185d8447d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 09 Jun 2026 18:25:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ambroseliew1998/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 Create a 2x2 Grid with Flexbox]]></title>
            <link>https://medium.com/@ambroseliew1998/how-to-create-a-2x2-grid-with-flexbox-623edf6d7143?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/623edf6d7143</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 05:55:43 GMT</pubDate>
            <atom:updated>2023-06-28T05:56:15.251Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fwzLR_mEB6J1bxhM" /><figcaption>Photo by <a href="https://unsplash.com/@linkedinsalesnavigator?utm_source=medium&amp;utm_medium=referral">LinkedIn Sales Solutions</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For context, I was asked this question during a TikTok frontend interview, and I initially thought it was a trick question.<br>I replied it was not possible with flexbox and that it was only possible with CSS Grid.<br>After the interview, I was curious and decided to do a quick google. And it turns out it is actually possible with flexbox.</p><h3>The Solution</h3><p>The solution to this trick question is to use the flex-wrap property.<br>If you are not familiar with the flex-wrap property, it is used to wrap items to the next row or column when the items exceed the container’s width or height.</p><h3>Demo in Action</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*qvpyHnnbUf2oUPXoMZqfmQ.png" /><figcaption>2x2 Grid</figcaption></figure><pre>export default function BasicDemo() {<br>  return (<br>    &lt;div<br>      style={{<br>        display: &quot;flex&quot;,<br>        flexWrap: &quot;wrap&quot;,<br>        width: &quot;200px&quot;,<br>        height: &quot;200px&quot;,<br>      }}<br>    &gt;<br>      &lt;div<br>        style={{ width: &quot;100px&quot;, height: &quot;100px&quot;, backgroundColor: &quot;#ccc&quot; }}<br>      &gt;&lt;/div&gt;<br>      &lt;div<br>        style={{ width: &quot;100px&quot;, height: &quot;100px&quot;, backgroundColor: &quot;#eee&quot; }}<br>      &gt;&lt;/div&gt;<br>      &lt;div<br>        style={{ width: &quot;100px&quot;, height: &quot;100px&quot;, backgroundColor: &quot;#eee&quot; }}<br>      &gt;&lt;/div&gt;<br>      &lt;div<br>        style={{ width: &quot;100px&quot;, height: &quot;100px&quot;, backgroundColor: &quot;#ccc&quot; }}<br>      &gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Demo is done using JSX, you can think of the style as inline styles in HTML.</p><blockquote>Check out the full demo <a href="https://ambrose.vercel.app/blog/2x2-grid-flexbox"><strong>here.</strong></a></blockquote><h3>Conclusion</h3><p>However, I would advise against this because the CSS Grid was specifically created for this use case and is much more intuitive to use.<br>Do not try to use this flexbox trick in production or in a large project, because it is unintuitive and personally I feel it is a hacky solution.</p><p>If an interviewer asks you this question, I think the best reply would be to try to convince him that CSS Grid is the best option forward while being as polite as you can.</p><p>I hope that after you have read this article, you would be prepared to face this terrible and unpractical question in your next frontend interview. 🙃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=623edf6d7143" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Index Of My Articles]]></title>
            <link>https://medium.com/@ambroseliew1998/index-of-my-articles-9e69f6fc892e?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e69f6fc892e</guid>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Mon, 17 Apr 2023 08:51:39 GMT</pubDate>
            <atom:updated>2023-04-17T09:02:01.712Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a list of all the articles that I have written in an easy-to-read format.</p><h4>HTML 🏢</h4><h4>CSS 🎨</h4><ul><li><a href="https://medium.com/@ambroseliew1998/sass-scss-sucks-and-here-is-why-3db9d929d8ca">SASS/SCSS Sucks and Here is Why.</a></li><li><a href="https://medium.com/@ambroseliew1998/stop-writing-important-in-your-css-code-and-do-this-instead-62171f86016f">Stop Writing !important in your CSS Code, and Do This Instead!</a></li><li><a href="https://medium.com/@ambroseliew1998/most-developers-fail-this-simple-css-interview-question-css-specificity-8e8b4d267e9b">Most Developers Fail This Simple CSS Interview Question (CSS Specificity)</a></li></ul><h4>JavaScript 🪄</h4><ul><li><a href="https://medium.com/@ambroseliew1998/the-only-situation-to-use-in-javascript-1b953b0a3b4b">The ONLY Situation To Use ‘==’ In JavaScript</a></li><li><a href="https://medium.com/@ambroseliew1998/3-ways-to-enforce-object-immutability-in-javascript-febcdc597aa8">3 Ways To Enforce Object Immutability In JavaScript</a></li><li><a href="https://medium.com/@ambroseliew1998/the-full-practical-guide-to-type-coercion-in-javascript-beware-of-these-3-common-mistakes-23028f150884">The Full Practical Guide To Type Coercion In JavaScript: Beware Of These 3 Common Mistakes</a></li></ul><h4>TypeScript 🛡️</h4><ul><li><a href="https://medium.com/@ambroseliew1998/never-say-never-the-never-keyword-in-typescript-and-exhaustive-matching-ebeaf57a93a3">Never Say Never, The never Keyword In TypeScript And Exhaustive Matching</a></li></ul><h4>React ⚛️</h4><ul><li><a href="https://medium.com/@ambroseliew1998/why-does-my-useeffect-call-twice-in-react-18-3a8f6f199102">Why does my useEffect call twice in React 18?!</a></li></ul><h4>Web Dev 🌐</h4><ul><li><a href="https://medium.com/@ambroseliew1998/core-web-vitals-what-are-they-739a0b7353fc">Core Web Vitals, What are they?</a></li><li><a href="https://medium.com/@ambroseliew1998/include-this-design-pattern-in-your-next-project-9adfff6fabd6">Include this Design Pattern in your next project!</a></li></ul><p>You can ensure that this page is always up-to-date, and make sure to keep your eyes peeled! Because I have many more articles that I want to share with you! 👀</p><p>And if you want to receive notifications about when I publish 🔔, <br>Subscribe to my Email Newsletter here! <a href="/@ambroseliew1998/subscribe?source=about_page-------------------------------------">https://medium.com/@ambroseliew1998/subscribe</a></p><p>If you want to help support me in creating the best content for you 🥰, <br>Click on the link here! <a href="/@ambroseliew1998/membership?source=about_page-------------------------------------">https://medium.com/@ambroseliew1998/membership</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e69f6fc892e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Full Practical Guide To Type Coercion In JavaScript: Beware Of These 3 Common Mistakes]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/the-full-practical-guide-to-type-coercion-in-javascript-beware-of-these-3-common-mistakes-23028f150884?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/1024/1*MpYDyNOCUdcEWuEbo1LsTA.png" width="1024"></a></p><p class="medium-feed-snippet">Ever used &#x2018;==&#x2019; in JavaScript?
Or &#x2018;if (x)&#x2019; in JavaScript?
Or used String Concatenation?</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/the-full-practical-guide-to-type-coercion-in-javascript-beware-of-these-3-common-mistakes-23028f150884?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/the-full-practical-guide-to-type-coercion-in-javascript-beware-of-these-3-common-mistakes-23028f150884?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/23028f150884</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Wed, 22 Mar 2023 07:16:18 GMT</pubDate>
            <atom:updated>2023-03-26T01:54:00.295Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[3 Ways To Enforce Object Immutability In JavaScript]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/3-ways-to-enforce-object-immutability-in-javascript-febcdc597aa8?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/1024/1*a8nNY1e1a7F6mhvS4gJ1Ww.png" width="1024"></a></p><p class="medium-feed-snippet">What happens when an Unstoppable Force meets an Immutable Object?</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/3-ways-to-enforce-object-immutability-in-javascript-febcdc597aa8?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/3-ways-to-enforce-object-immutability-in-javascript-febcdc597aa8?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/febcdc597aa8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 00:55:43 GMT</pubDate>
            <atom:updated>2023-03-19T00:55:43.325Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Never Say Never, The never Keyword In TypeScript And Exhaustive Matching]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/never-say-never-the-never-keyword-in-typescript-and-exhaustive-matching-ebeaf57a93a3?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/600/1*7BtXXIgGc_gT8zXEoujiVA.png" width="600"></a></p><p class="medium-feed-snippet">Ever heard of the never keyword in TypeScript and know when to use it?</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/never-say-never-the-never-keyword-in-typescript-and-exhaustive-matching-ebeaf57a93a3?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/never-say-never-the-never-keyword-in-typescript-and-exhaustive-matching-ebeaf57a93a3?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebeaf57a93a3</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 04:24:32 GMT</pubDate>
            <atom:updated>2023-03-11T11:05:46.062Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Most Developers Fail This Simple CSS Interview Question (CSS Specificity)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/most-developers-fail-this-simple-css-interview-question-css-specificity-8e8b4d267e9b?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/828/1*useg7xOof7Qr4PZMtvta5w.png" width="828"></a></p><p class="medium-feed-snippet">Think CSS is easy? Think again!</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/most-developers-fail-this-simple-css-interview-question-css-specificity-8e8b4d267e9b?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/most-developers-fail-this-simple-css-interview-question-css-specificity-8e8b4d267e9b?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e8b4d267e9b</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Wed, 25 Jan 2023 07:28:21 GMT</pubDate>
            <atom:updated>2023-02-07T03:18:16.937Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The ONLY Situation To Use ‘==’ In JavaScript]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/the-only-situation-to-use-in-javascript-1b953b0a3b4b?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/1080/1*wQvuYgDodBph-d7_AyQKWw.png" width="1080"></a></p><p class="medium-feed-snippet">Ever pondered when to use &#x2018;==&#x2019; in JavaScript?
Or ever had the idea that one should always use &#x2018;===&#x2019; in JavaScript?
Hopefully, by reading&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/the-only-situation-to-use-in-javascript-1b953b0a3b4b?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/the-only-situation-to-use-in-javascript-1b953b0a3b4b?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b953b0a3b4b</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 09:53:57 GMT</pubDate>
            <atom:updated>2023-03-22T07:20:37.865Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[SASS/SCSS Sucks and Here is Why.]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/sass-scss-sucks-and-here-is-why-3db9d929d8ca?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/1072/1*B8_ksfx1cnyWheAVbsX1RA.png" width="1072"></a></p><p class="medium-feed-snippet">Ditch the Preprocessors and Embrace Modern CSS</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/sass-scss-sucks-and-here-is-why-3db9d929d8ca?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/sass-scss-sucks-and-here-is-why-3db9d929d8ca?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3db9d929d8ca</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[sass]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Sun, 13 Nov 2022 10:27:49 GMT</pubDate>
            <atom:updated>2023-01-06T09:22:36.352Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stop Writing !important in your CSS Code, and Do This Instead!]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@ambroseliew1998/stop-writing-important-in-your-css-code-and-do-this-instead-62171f86016f?source=rss-2d185d8447d0------2"><img src="https://cdn-images-1.medium.com/max/2600/0*p-AayuO3yv3OoSti" width="6000"></a></p><p class="medium-feed-snippet">Ever wrote&#xA0;!important in your CSS file to override a CSS property?&#xA0;
Come learn CSS Specificity to remove the need to write&#xA0;!important ever&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@ambroseliew1998/stop-writing-important-in-your-css-code-and-do-this-instead-62171f86016f?source=rss-2d185d8447d0------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@ambroseliew1998/stop-writing-important-in-your-css-code-and-do-this-instead-62171f86016f?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/62171f86016f</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Wed, 09 Nov 2022 10:57:57 GMT</pubDate>
            <atom:updated>2023-02-06T11:07:25.222Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Why does my useEffect call twice in React 18?!]]></title>
            <link>https://medium.com/@ambroseliew1998/why-does-my-useeffect-call-twice-in-react-18-3a8f6f199102?source=rss-2d185d8447d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a8f6f199102</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react18]]></category>
            <category><![CDATA[useeffect]]></category>
            <category><![CDATA[strict-mode]]></category>
            <dc:creator><![CDATA[Ambrose Liew]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 10:41:18 GMT</pubDate>
            <atom:updated>2023-01-15T03:15:32.433Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>TLDR: Make sure to clean up your useEffects functions correctly.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4CsWZvv5gBYyKacw" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In React 18, they introduce this new feature in Strict Mode, where they mount, unmount, and then remount your components during <strong>development mode only,</strong> to detect unsafe lifecycle methods and ensure that you are using useEffect correctly.</p><p>This is to simulate a situation where your components get remounted quickly again <em>(which happens often, but we rarely vigorously test this scenario)</em>, and to see what the outcome of our components is.</p><p>Since React heavily focuses on <strong>Idempotence,<br></strong><em>(See: </em><a href="https://overreacted.io/react-as-a-ui-runtime/#purity"><em>Blog by Dan Abramov</em></a><em> and </em><a href="https://beta.reactjs.org/learn/keeping-components-pure"><em>Post by Official React Docs</em></a><em>)</em><br>You must ensure that whenever your component gets mounted, unmounted, and then remounted again, the same outcomes are expected to be observed.</p><blockquote>So do I work around Strict Mode or do I need to avoid Strict Mode all together?</blockquote><p><strong>No!</strong> The correct solution to this question is to not look for a hacky solution like using refs to avoid double firing, or disabling Strict Mode, but to instead <a href="https://www.youtube.com/watch?v=j8s01ThR7bQ">embrace double firing</a> and also to <a href="https://www.youtube.com/watch?v=HPoC-k7Rxwo"><strong>consider whether you really need to use useEffect.</strong></a></p><p>There is also a <a href="https://beta.reactjs.org/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development">detailed solution by the React core team</a>. Talking about how if you must use useEffect, make sure your cleanup functions are written correctly!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a8f6f199102" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>