<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Abdullah Ola Mudathir</title>
    <description>The latest articles on Forem by Abdullah Ola Mudathir (@cruxcodes).</description>
    <link>https://forem.com/cruxcodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3392468%2F92c25b30-b853-4fea-b706-ca45701af623.png</url>
      <title>Forem: Abdullah Ola Mudathir</title>
      <link>https://forem.com/cruxcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cruxcodes"/>
    <language>en</language>
    <item>
      <title>Stop Re-rendering: React Memoization Guide</title>
      <dc:creator>Abdullah Ola Mudathir</dc:creator>
      <pubDate>Sun, 23 Nov 2025 18:29:47 +0000</pubDate>
      <link>https://forem.com/cruxcodes/memoization-as-a-beginner-in-react-27f9</link>
      <guid>https://forem.com/cruxcodes/memoization-as-a-beginner-in-react-27f9</guid>
      <description>&lt;p&gt;Memoization is a technique used to improve performance by optimizing and storing the results of expensive functions. This is done by caching results and returning cached results when the same calls occur again with no change.&lt;/p&gt;

&lt;p&gt;Like your brain, the computer uses its memory to perform programs. Just like you don’t have to go back to relearn information you remember, the computer uses previously cached results when there is no change instead of performing the task again. &lt;/p&gt;

&lt;h3&gt;
  
  
  Memoization in React
&lt;/h3&gt;

&lt;p&gt;Memoization in React can be achieved with the following: &lt;/p&gt;

&lt;p&gt;React is a JavaScript library used to build user interfaces for the web. On the premise that you’re not a beginner, I’ll be talking about how to achieve memoization in React.&lt;/p&gt;

&lt;h4&gt;
  
  
  React’s useMemo
&lt;/h4&gt;

&lt;p&gt;The useMemo hook that React offers is used to cache the results of expensive functions.&lt;/p&gt;

&lt;p&gt;It simply caches the result of the computation, and only when the dependencies or arguments change would it recalculate the computation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const valueToBeMemoized = useMemo(function(){},[dependencies])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const memoizedValue = useMemo(() =&amp;gt; {
    return expensiveComputationFunction(args);
  }, [args]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever the argument(args) changes, the memoizedValue reruns the expensiveComputationFunction and stores its value. If useMemo is to be used in your application, make sure the function doesn't modify any external state, i.e., the function should only be based on its input and not hold the power to mutate values outside its scope. &lt;/p&gt;

&lt;h4&gt;
  
  
  React.memo()
&lt;/h4&gt;

&lt;p&gt;A memoized component changes only when the props are changed. Like the useMemo hook, the main thing here is dependencies/props that do not mutate often. Essentially, this tells React that if props don't change, don't rerender the component, use the existing component instead.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzr3w7fh90z7xaxb5yk6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzr3w7fh90z7xaxb5yk6m.png" alt="Image of react memo" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  React useCallback
&lt;/h4&gt;

&lt;p&gt;The useCallback function, unlike React.memo, caches functions if the dependencies are unchanged.&lt;/p&gt;

&lt;p&gt;In JavaScript, when applications are run, functions generate references. With every rerender, the function generates a new reference. The useCallback creates a function once and memoizes its identity(the reference).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const functionName = useCallback(() =&amp;gt; {
    //function to be performed
  }, [args]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each render === a new function reference. useCallback helps reduce this.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to memoize
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If a certain component is slow due to expensive functions, and you notice a drag in website responsiveness.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A function has to perform expensive functions, but the props rarely change. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the component isn’t going to be mutated often, memoize it to reduce rerenders, for example, if you have a component dependent on a form.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  When not to memoize
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Cheap/fast components: if it's not an expensive function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Props change frequently anyway&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Premature optimization: Memoization should not be your initial go-to for performance optimization.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  React Update
&lt;/h3&gt;

&lt;p&gt;On the 7th of October, React launched the stable React Compiler 1.0. This new update works to automatically optimize components and hooks, reducing the need for manual memoization. &lt;br&gt;
To install :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev --save-exact babel-plugin-react-compiler@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read more: &lt;a href="https://react.dev/blog/2025/10/07/react-compiler-1" rel="noopener noreferrer"&gt;https://react.dev/blog/2025/10/07/react-compiler-1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When working on an existing application, slowly inject this new update into your application instead of an all-out refactor. &lt;/p&gt;

&lt;p&gt;Remember: Test before memoizing, optimize before memoizing, as overuse of memoization can lead to performance issues.&lt;/p&gt;

&lt;p&gt;There are other use cases for memoization, but overusing memoization impacts performance as well. Try to optimize your application without the need for memoization and understand the problem you're trying to fix and whether to memoize is the right thing to do.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>CSS Office Art: The Work</title>
      <dc:creator>Abdullah Ola Mudathir</dc:creator>
      <pubDate>Sun, 27 Jul 2025 22:45:20 +0000</pubDate>
      <link>https://forem.com/cruxcodes/css-office-art-the-work-3nk5</link>
      <guid>https://forem.com/cruxcodes/css-office-art-the-work-3nk5</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/frontend/axero"&gt;Frontend Challenge: Office Edition sponsored by Axero, CSS Art: Office Culture&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;My css art was built around a typical work day, just a pictoral representation of a day doing work. I went through the css prompt for the hackathon and brainstormed on what I could build to showcase this.&lt;br&gt;
I was able to sketch what I envisioned and did some research online to find an image or an animated version of something close to my thought process. This was so i could have a pictoral representation of what I needed to build. Image I was inspired by: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F776ih1df8pd2jyl96gu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F776ih1df8pd2jyl96gu9.png" alt=" " width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pabekp2o40es6deli6v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pabekp2o40es6deli6v.png" alt="Image of demo" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fployrobo1l5g3zmbsc3z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fployrobo1l5g3zmbsc3z.png" alt="Demo image" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The code is available:&lt;/strong&gt; &lt;a href="https://github.com/Cruxcodes/CSS-Office-Art" rel="noopener noreferrer"&gt;https://github.com/Cruxcodes/CSS-Office-Art&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live View:&lt;/strong&gt; &lt;a href="https://office-css-art.netlify.app/" rel="noopener noreferrer"&gt;https://office-css-art.netlify.app/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;It was a brain teasing journey. I had to zoom in and zoom out constantly to make sure each border was round enough or to discern if the div had to be closer or not. &lt;br&gt;
It was a fun project. I enjoyed getting the animations to work, each win was really great. I also learnt new things building the project. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linear gradient&lt;/strong&gt;: Depending on your skill with css, you already know how linear-gradient works with css. When i was trying to build the boxes I found it redundant to use two divs and didn't want to go through using box shadows. I found out you can use linear gradient to create solid colors.
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5w7p1ukgq6hfqn5pldwc.png" alt="Linear gradient showcase" width="273" height="324"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;background-image: linear-gradient(to right, #ea3b60 40.5%, #ff506d 0%);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;By setting the second property to 0%, the color starts from where the previous color ends. Since there is no space or break for colors to blend, it creates the solid colors side by side.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Animations&lt;/strong&gt;: I was able to explore many new things with css animations. The one thing I'm most proud of is the swing of the banner. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Seeing the website go from just boxes to something that looks good is an achievement I would like to share. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbk1un6km4laogp2sbnaj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbk1un6km4laogp2sbnaj.png" alt="Beginning stages of development" width="800" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftekllmq22lvbf18p9gni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftekllmq22lvbf18p9gni.png" alt="Progress of development" width="497" height="934"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ygyb78g0dyjeaskcwcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ygyb78g0dyjeaskcwcg.png" alt="Progress of development" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foca3m6r1q8bl1wfbthc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foca3m6r1q8bl1wfbthc3.png" alt="Progress of development" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Git commit messages&lt;/strong&gt;: I made use of conventional commits for most of my uploads but i was able to use vscode's ai to generate commit messages to push to my git repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also improved my mastery with css properties like z-index, the position elements, variables in css, the before and after properties. I was able to minimize creating too many divs by making use of the properties css provides. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsiveness : To deal with responsiveness, I made use of the scale property in css as well as the media queries.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @media screen and (max-width: 768px) {
    left: 50%;
    bottom: 10%;
    transform: translateX(-50%) scale(0.8);
  }
  @media screen and (max-width: 600px) {
    left: 50%;
    bottom: 10%;
    transform: translateX(-50%) scale(0.6);
  }
  @media screen and (max-width: 500px) {
    left: 50%;
    bottom: 10%;
    transform: translateX(-50%) scale(0.4);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfx2osmi0kus4hso38mn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqfx2osmi0kus4hso38mn.png" alt="Responsiveness" width="677" height="855"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyiu4egspidp6frz2zu4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyiu4egspidp6frz2zu4.png" alt="Responsiveness" width="327" height="867"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is definitely room for improvement but i was able to make the css art scale just enough that it would be compatible across devices. &lt;/p&gt;

&lt;h2&gt;
  
  
  Open source additions.
&lt;/h2&gt;

&lt;p&gt;I also was able to use open source code to improve my css art. I made use of a &lt;a href="https://codepen.io/creme/pen/rdjXav" rel="noopener noreferrer"&gt;codepen addition&lt;/a&gt; to add the animations for the eyes of character. I also made use of &lt;a href="https://codepen.io/NadaSadek/pen/xxRgZbq" rel="noopener noreferrer"&gt;NadaSadek's coffee steam&lt;/a&gt; for my own coffee cup.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Coffee Steam :&lt;a href="https://codepen.io/NadaSadek/pen/xxRgZbq" rel="noopener noreferrer"&gt;https://codepen.io/NadaSadek/pen/xxRgZbq&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Eyes : &lt;a href="https://codepen.io/creme/pen/rdjXav" rel="noopener noreferrer"&gt;https://codepen.io/creme/pen/rdjXav&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This was a fun experience and I really enjoyed making css art that tells a story. Office culture definitely isn't just about working, the friends you make, lunch you have, handshakes you exchange, they all form their own little part of your office story.&lt;/p&gt;

&lt;h2&gt;
  
  
  License
&lt;/h2&gt;

&lt;p&gt;The work is licensed under the &lt;a href="https://github.com/Cruxcodes/CSS-Office-Art/tree/main?tab=MIT-1-ov-file#" rel="noopener noreferrer"&gt;MIT License&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The code is available:&lt;/strong&gt; &lt;a href="https://github.com/Cruxcodes/CSS-Office-Art" rel="noopener noreferrer"&gt;https://github.com/Cruxcodes/CSS-Office-Art&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live View:&lt;/strong&gt; &lt;a href="https://office-css-art.netlify.app/" rel="noopener noreferrer"&gt;https://office-css-art.netlify.app/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontendchallenge</category>
      <category>devchallenge</category>
      <category>css</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
