<?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 Hamza Mellahi on Medium]]></title>
        <description><![CDATA[Stories by Hamza Mellahi on Medium]]></description>
        <link>https://medium.com/@hmellahi?source=rss-2ebd6e6f9505------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Hamza Mellahi on Medium</title>
            <link>https://medium.com/@hmellahi?source=rss-2ebd6e6f9505------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 07:37:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hmellahi/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 Islamic Teachings Can Improve Your Life]]></title>
            <link>https://medium.com/@hmellahi/islam-has-been-teaching-optimal-living-for-1400-years-d57d9ef98d52?source=rss-2ebd6e6f9505------2</link>
            <guid isPermaLink="false">https://medium.com/p/d57d9ef98d52</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[islam]]></category>
            <category><![CDATA[productivity-hacks]]></category>
            <dc:creator><![CDATA[Hamza Mellahi]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 02:27:00 GMT</pubDate>
            <atom:updated>2026-10-05T20:21:41.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Islamic Teachings Can Improve Your Life" src="https://cdn-images-1.medium.com/max/1024/0*dWmQDE8DxseZH9ob.png" /></figure><p>Recently I learned that studying Islam <strong>MORE</strong> can improve your life, even if you aren’t Muslim. From how you deal with people, to business, self-discipline, and even simple daily habits.</p><p>For example, Islam obligates Muslims to pray daily around 5AM. And it isn’t a random rule.</p><p>It requires maintaining an early and consistent sleep schedule, which leads to better focus, more energy, and overall well-being. Plus you get extra time before the day even starts.</p><p>Also Going to the mosque isn’t just a chore. It’s a place where Muslims can meet and connect with one another, making it easier to build friendships, strengthen community ties, and sometimes even find opportunities for collaboration or business or marriage….It can also help reduce isolation by bringing people into real-life social spaces instead of being stuck in the cycle of constant online interaction and social media use.</p><p>More details about mosque<strong>:</strong> <a href="https://www.youtube.com/watch?v=LgEUxjLGPXE">YouTube Video</a></p><p>If you wanna learn more, I’ve shared a list of Resources I learn from in English, Arabic, and Darija.</p><h3>📚 Recommended Books</h3><p>Some great Arabic books available in English too:</p><ul><li><a href="https://www.amazon.fr/-/en/uniquement-taille-interm%C3%A9diaire-pratique-hardcover/dp/3941775235/ref=sr_1_2?crid=127CQGHFXN0CH&amp;dib=eyJ2IjoiMSJ9.erlYynN4kklWXW5k4czjka9zEu99VSAGakynrzf0MqUUdix7Dxzyy9ZvvuOpuWIu5BcbVLy-l6eYizCdM5cRllU04aXBedoxd9Bj8pf362rbDdNxGyH7t4xtBf8ZhliEt4jGXNXRZSy3sA_kXpfMtwWUj35lsFfiQvVYWjKJMFqmrsx8HgRP7KDfGSA-3y5ExLw5FehOHpEL-ygRLASHJGnPZXY7Nqs5PYT6YfOVUU5BbKq0wDlsyAWqUVjvD3-Rmf34QThDMRbK6q_9_RoNQ_9Qaj8B1zlLYKWb0FG5shg.hTvme-Fn_ReTv-0u1fuUUmkPRvP8c-7Vds5sZYG9x6o&amp;dib_tag=se&amp;keywords=quran+arabic&amp;qid=1780636772&amp;sprefix=quran+arabi,aps,184&amp;sr=8-2">Quran</a> — English translations are available, though some meanings can be lost in translation.</li><li><a href="https://www.amazon.fr/Dont-Sad-Aaidh-Abdullah-Al-Qarni/dp/1643543466">Don’t Be Sad</a> — Aaidh Abdullah Al-Qarni</li><li><a href="https://www.amazon.in/Disease-%D8%A3%D9%8E%D9%84%D8%AF%D9%91%D8%A7%D8%A1%D9%8F-%D9%88%D9%8E%D8%A7%D9%84%D8%AF%D9%91%D9%8E%D9%88%D9%8E%D8%A7%D8%A1%D9%8F-English-Language/dp/B0B5VY58QW">The Disease and the Cure</a> — Ibn Al-Qayyim</li><li>More books <a href="https://gitlab.com/hamza_mellahi/muslim-lifestyle-hub/-/blob/main/content/resources/content/recommended-books.md">here</a></li></ul><p>Don’t watch only “A 10-minute summary” of these books, you will miss a lot.</p><figure><img alt="a baby wearing a striped shirt is covering his face with his hand" src="https://cdn-images-1.medium.com/max/510/0*z5NTYLKOEmkN1bG-.gif" /></figure><p>Also, am following this <a href="https://youtu.be/R58mZ29CWmI?si=MQR2RGQHHfBVlrLk">study program</a>.</p><p>I’ll keep updating this list over time as I discover more useful resources</p><h3>Credits</h3><p>Thanks to <a href="https://www.linkedin.com/in/abdellalim-benouda/">Abdellalim</a> and <a href="https://www.linkedin.com/in/muhammad-rassam/">Mohamed</a> for reviewing this article.</p><p>Inspired by <a href="https://www.youtube.com/watch?v=AOsw7lzTTX0">Deen WITH Dunya</a> — a khutbah by Nouman Ali Khan.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d57d9ef98d52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your App faster using Optimistic Updates]]></title>
            <link>https://medium.com/@hmellahi/make-your-app-faster-using-optimistic-updates-56072a3889fb?source=rss-2ebd6e6f9505------2</link>
            <guid isPermaLink="false">https://medium.com/p/56072a3889fb</guid>
            <category><![CDATA[performance-optimization]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[optimistic-update]]></category>
            <category><![CDATA[react-query]]></category>
            <dc:creator><![CDATA[Hamza Mellahi]]></dc:creator>
            <pubDate>Tue, 06 Feb 2024 23:31:03 GMT</pubDate>
            <atom:updated>2025-11-17T14:21:20.669Z</atom:updated>
            <content:encoded><![CDATA[<h3>Table of Contents</h3><p>· <a href="#5ed4">Introduction</a><br>· <a href="#8edd">What’s an optimistic update?</a><br>· <a href="#314b">Use case example</a><br> ∘ <a href="#e5f3">Without optimistic update </a><br> ∘ <a href="#465b">With an optimistic update</a><br>· <a href="#3ba4">Next Steps</a><br>· <a href="#7f57">Conclusion</a><br>· <a href="#4355">Acknowledgment</a></p><h3>Introduction</h3><p>In this article, we will discuss what is an optimistic update and how to implement it in your React app to make it feel faster and more responsive, using React Query.</p><h3>What’s an optimistic update?</h3><p>When doing operations that involve waiting for external services, like an <strong>API call</strong> that will mostly succeed, we <strong>proactively</strong> update the UI. This approach improves the user experience, making it better and smoother.</p><h3>Use case example</h3><p>Imagine you have a list of todos, and we have to add a delete action in the frontend to remove a todo.</p><h4>Without optimistic update</h4><p>When the users click on delete, we will:</p><ol><li>Send a request to the backend to delete the todo.</li><li>Once we receive a response, refresh the todos list.</li><li>the todo will be removed from the UI.</li></ol><p>Here is a code example with React Query:</p><pre>export default function useDeleteTodo() {<br>  // Get the query client instance for managing queries<br>  const queryClient = useQueryClient();<br><br>  // Use the useMutation hook to create the deleteTodo mutation<br>  const { isLoading: isDeleting, mutate } = useMutation({<br>    // Define the mutation function that will delete the todo<br>    mutationFn: (id) =&gt; deleteTodo(id),<br><br>    // Refetch todos after the success of todo deletion<br>    // to removed the todo from the UI<br>    onSuccess: () =&gt; {<br>      queryClient.invalidateQueries({<br>        queryKey: [&quot;todos&quot;],<br>      });<br>    },<br>  });<br><br>  // Return the loading state and mutate function<br>  return [isDeleting, mutate];<br>}</pre><p>In this example, we use the useMutation hook, which takes:</p><ul><li>mutationFn : It takes the async function to delete the todo in the backend.</li><li>onSuccess : it is called when the mutation is finished, and in this example, we refetch the todos list, so that the deleted todo is removed from the UI.</li></ul><h4>With an optimistic update</h4><p>When the users click on delete, we will :</p><ol><li>Remove the todo from the UI (assuming successful backend deletion).</li><li>Send a request to the backend to delete the todo.</li><li>In case of failure, restore the list to its state before deletion.</li></ol><p>Unlike the first approach, the deletion of the todo will look like it’s instant since we won’t wait for the <strong>API call</strong> response to <strong>update</strong> the UI.</p><p>The code with an optimistic update :</p><pre><br>const queryKey = &quot;todos&quot;;<br><br>export default function useDeleteTodo() {<br>  const queryClient = useQueryClient();<br><br>  const { isLoading: isDeleting, mutate } = useMutation({<br>    mutationFn: (id) =&gt; deleteTodo(id),<br>    // When mutate is called:<br>    onMutate: async (todoToDeleteId) =&gt; {<br>      // Cancel any outgoing refetches<br>      // so they don&#39;t overwrite our optimistic update<br>      await queryClient.cancelQueries(queryKey);<br><br>      // Snapshot the previous value<br>      const previousTodos = queryClient.getQueryData([queryKey]);<br><br>      // Optimistically update the local state by removing the todo<br>      queryClient.setQueryData([queryKey], (oldTodos) =&gt;<br>        oldTodos.filter((todo) =&gt; todo.id != todoToDeleteId)<br>      );<br><br>      // Return a context object with the snapshotted value<br>      return { previousTodos };<br>    },<br>    // If the mutation fails<br>    // use the context returned from onMutate to roll back<br>    onError: (err, todoToDeleteId, context) =&gt; {<br>      queryClient.setQueryData([queryKey], context.previousTodos)<br>    },<br>  });<br><br>  return [isDeleting, mutate];<br>}</pre><p>We added onMutate which will take the todoToDeleteId, it will be executed before the mutation is happening (in this case, delete todo).</p><ol><li>Cancel any outgoing fetches (so they don’t overwrite our optimistic update).</li><li>Take a snapshot of the previous todos.</li><li>Remove the todo in the local state, which removes the todo from the UI.</li><li>Returns the snapshot as a context (will be used later to roll back in case of failure).</li></ol><p>We added an onError callback, which is called in case of failure. It utilizes the context returned to roll back to the old data.</p><p>Additionally, we removed the onSuccess callback since we have already removed the todo from the UI and won&#39;t need to refetch.</p><h3>Next Steps</h3><p>You may want to acknowledge the user about the success or failure of the deletion to enhance the user experience. For instance, by displaying a toast notification for both error and success scenarios.</p><h3>Conclusion</h3><p>In a nutshell, optimistic updates make your application feel faster. It’s like a quick tweak to the user interface before the backend responds, ensuring a smoother user experience.</p><p>Consider adding optimistic updates to your code for a more visually responsive interface and the impression of smoother app performance.</p><h3>Acknowledgment</h3><p>Many Thanks to <a href="https://www.linkedin.com/in/ali-guedda/">Ali Guedda</a> for reviewing this article.</p><p>Thank you for reading, and happy coding!</p><p><em>Originally published at </em><a href="https://frontwizards.com/">https://frontwizards.com/</a><em> on February 6, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56072a3889fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>