<?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 Mohamed Hassan Noor on Medium]]></title>
        <description><![CDATA[Stories by Mohamed Hassan Noor on Medium]]></description>
        <link>https://medium.com/@MohamedHNoor?source=rss-1e15a73b51d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*q1E0m9kqEflDNjoV</url>
            <title>Stories by Mohamed Hassan Noor on Medium</title>
            <link>https://medium.com/@MohamedHNoor?source=rss-1e15a73b51d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:51:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@MohamedHNoor/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[Mastering Through Associations in Ruby on Rails: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@MohamedHNoor/mastering-through-associations-in-ruby-on-rails-a-step-by-step-guide-eee14c4bc83b?source=rss-1e15a73b51d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/eee14c4bc83b</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[rails-associations]]></category>
            <category><![CDATA[many-to-many-relationship]]></category>
            <dc:creator><![CDATA[Mohamed Hassan Noor]]></dc:creator>
            <pubDate>Tue, 24 Sep 2024 15:59:19 GMT</pubDate>
            <atom:updated>2024-09-24T15:59:19.595Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with Ruby on Rails, setting up associations between models is a powerful tool to simplify database interactions. In this guide, we’ll explore through associations, focusing on many-to-many relationships between users and their favorite movies. By the end of this, you’ll be able to set up a “Fave” button on movie pages and display users’ favorite movies on their profiles, creating a seamless user experience.</p><h3>Part 1: Setting Up Through Associations</h3><h4>Objective</h4><p>The goal here is to create a direct association between users and movies through a favorites system. Instead of navigating from a user to their favorites and then to movies (or vice versa), we’ll simplify it by directly linking users with their favorite movies and movies with their fans (users).</p><h3>Step 1: Declaring Through Associations</h3><p>We begin with three models: User, Movie, and Favorite. A favorite belongs to both a user and a movie, and both User and Movie have many favorites.</p><p>Here’s what the Movie model looks like:</p><pre>class Movie &lt; ApplicationRecord<br>  has_many :reviews, dependent: :destroy<br>  has_many :favorites, dependent: :destroy<br>  has_many :fans, through: :favorites, source: :user<br>end</pre><p>The has_many :fans association creates a direct link between a movie and its fans, going through the favorites table. Next, we need to set up a similar association in the User model:</p><pre>class User &lt; ApplicationRecord<br>  has_many :reviews, dependent: :destroy<br>  has_many :favorites, dependent: :destroy<br>  has_many :favorite_movies, through: :favorites, source: :movie<br>end</pre><p>Now, both models are equipped to directly connect users with their favorite movies and vice versa. With just these two lines, Rails handles all the heavy lifting of navigating the relationship in a single query.</p><h3>Step 2: Experimenting with the Console</h3><p>Now that we’ve declared the associations, let’s test them in the Rails console.</p><p>First, retrieve a movie and check its fans:</p><pre>movie = Movie.find_by(title: &quot;Movie-1&quot;)<br>movie.fans</pre><p>This returns an array of users who have favorited the movie. The SQL query behind this uses a INNER JOIN to combine the users and movies through the favorites table.</p><p>Similarly, you can retrieve a user’s favorite movies:</p><pre>user = User.find_by(name: &quot;Mohamed&quot;)<br>user.favorite_movies</pre><p>Again, this executes a single query to fetch all the movies a user has favorited. Pretty efficient, right?</p><h3>Step 3: Listing a Movie’s Fans</h3><p>Let’s display the fans of a movie on its show page. In the MoviesController, fetch the fans and assign them to an instance variable:</p><pre>def show<br>  @movie = Movie.find(params[:id])<br>  @fans = @movie.fans<br>end</pre><p>Next, in the show template, list the fans:</p><pre>&lt;div&gt;<br>  &lt;% if @fans.present? %&gt;<br>    &lt;h4&gt;Fans&lt;/h4&gt;<br>    &lt;ul&gt;<br>      &lt;% @fans.each do |user| %&gt;<br>        &lt;li&gt;&lt;%= link_to user.name, user %&gt;&lt;/li&gt;<br>      &lt;% end %&gt;<br>    &lt;/ul&gt;<br>  &lt;% end %&gt;<br>&lt;/div&gt;</pre><p>If the movie has fans, their names will be displayed, each linking to their profile page.</p><h3>Step 4: Listing a User’s Favorite Movies</h3><p>To show a user’s favorite movies on their profile page, first, set up the data in the UsersController:</p><pre>def show<br>  @user = User.find(params[:id])<br>  @reviews = @user.reviews<br>  @favorite_movies = @user.favorite_movies<br>end</pre><p>In the user show template, list their favorite movies:</p><pre>&lt;% if @favorite_movies.present? %&gt;<br>  &lt;h3&gt;Favorite Movies&lt;/h3&gt;<br>  &lt;div&gt;<br>    &lt;% @favorite_movies.each do |movie| %&gt;<br>      &lt;%= link_to image_tag(movie.image_file_name), movie %&gt;<br>    &lt;% end %&gt;<br>  &lt;/div&gt;<br>&lt;% end %&gt;</pre><p>This ensures that users see their favorite movies with each movie image linked to its corresponding page.</p><h3>Part 2: Adding a “Fave” and “Unfave” Button</h3><h4>Objective</h4><p>We now need to add “Fave” and “Unfave” buttons to allow users to mark or unmark movies as their favorites.</p><h3>Step 1: Nesting the Favorite Resource</h3><p>First, nest the favorites resource inside movies to ensure that the movie ID is always included in the URL:</p><pre>resources :movies do<br>  resources :reviews<br>  resources :favorites, only: [:create, :destroy]<br>end</pre><p>This generates routes like:</p><ul><li>movie_favorites_path: POST /movies/:movie_id/favorites</li><li>movie_favorite_path: DELETE /movies/:movie_id/favorites/:id</li></ul><h3>Step 2: Generating the “Fave” Button</h3><p>On the movie show page, we’ll generate a “Fave” button that users can click to add the movie to their favorites. Here’s how it looks:</p><pre>&lt;% if current_user %&gt;<br>  &lt;div&gt;<br>    &lt;%= button_to &quot;♥️ Fave&quot;, movie_favorites_path(@movie) %&gt;<br>    &lt;div&gt;<br>      &lt;%= @fans.size %&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;% end %&gt;</pre><p>The button_to helper generates a form that posts the request to movie_favorites_path to create a favorite.</p><h3>Step 3: Implementing the Create Action</h3><p>Now, implement the create action in the FavoritesController to handle adding a favorite:</p><pre>class FavoritesController &lt; ApplicationController<br>  before_action :require_signin<br><br>  def create<br>    @movie = Movie.find(params[:movie_id])<br>    @movie.favorites.create!(user: current_user)<br>    redirect_to @movie<br>  end<br>end</pre><p>This action creates a new favorite for the signed-in user and redirects back to the movie’s show page.</p><h3>Step 4: Preventing Duplicate Faves</h3><p>To prevent users from favoriting the same movie multiple times, we’ll check if the movie is already a favorite. In the MoviesController, add:</p><pre>def show<br>  @movie = Movie.find(params[:id])<br>  @fans = @movie.fans<br>  @favorite = current_user.favorites.find_by(movie_id: @movie.id) if current_user<br>end</pre><p>Update the template to conditionally show the “Fave” or “Unfave” button:</p><pre>&lt;% if current_user %&gt;<br>  &lt;div&gt;<br>    &lt;% if @favorite %&gt;<br>      &lt;%= button_to &quot;♡ Unfave&quot;, movie_favorite_path(@movie, @favorite), method: :delete %&gt;<br>    &lt;% else %&gt;<br>      &lt;%= button_to &quot;♥️ Fave&quot;, movie_favorites_path(@movie) %&gt;<br>    &lt;% end %&gt;<br>    &lt;div&gt;<br>      &lt;%= @fans.size %&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;% end %&gt;</pre><h3>Step 5: Implementing the Destroy Action</h3><p>Finally, implement the destroy action to handle unfavoriting a movie:</p><pre>def destroy<br>  @movie = Movie.find(params[:movie_id])<br>  favorite = current_user.favorites.find(params[:id])<br>  favorite.destroy<br>  redirect_to @movie<br>end</pre><p>Now, users can remove movies from their favorites by clicking the “Unfave” button.</p><h3>Conclusion</h3><p>By setting up through associations and adding “Fave” and “Unfave” buttons, we’ve created a fully functional favoriting system that allows users to interact seamlessly with movies and their profiles. With minimal lines of code, Ruby on Rails enables powerful relationships between models, making features like this simple to implement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eee14c4bc83b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhance Your React App with Custom Star Ratings]]></title>
            <link>https://medium.com/@MohamedHNoor/enhance-your-react-app-with-custom-star-ratings-96aa44a26ba6?source=rss-1e15a73b51d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/96aa44a26ba6</guid>
            <category><![CDATA[components]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mohamed Hassan Noor]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 20:37:40 GMT</pubDate>
            <atom:updated>2024-07-23T20:37:40.431Z</atom:updated>
            <content:encoded><![CDATA[<p>When building a React application, you want your components to be as reusable as possible. This makes your code cleaner and saves you a lot of time in the long run. One of the most common features you might need is a star rating component. Whether for product reviews, user feedback, or any other rating system, having a reusable star rating component can be a game changer. Let’s dive into how you can create one that’s both flexible and easy to integrate.</p><h4>Start with the Basics</h4><p>First things first, you need to understand the basics of a star rating component. Essentially, it’s a visual representation of a rating, often out of five stars. Users can click on the stars to select their rating. Sounds simple enough, right? But when you think about making this component reusable, you need to consider a few more details.</p><p>For example, you want your component to be able to handle different numbers of stars, various sizes, and possibly even different shapes. You also need it to work seamlessly across different parts of your application. So, let’s start by creating a simple version and then gradually make it more robust.</p><h4>Building the Basic Component</h4><p>Let’s create a basic star rating component. You’ll start with a simple functional component in React. This component will render a series of stars, and each star will be clickable to set the rating. Here’s a simple example to get you started:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>const StarRating = ({ totalStars = 5 }) =&gt; {<br>    const [rating, setRating] = useState(0);<br><br>    const handleClick = (index) =&gt; {<br>        setRating(index + 1);<br>    };<br><br>    return (<br>        &lt;div&gt;<br>            {[...Array(totalStars)].map((star, index) =&gt; (<br>                &lt;span <br>                    key={index}<br>                    onClick={() =&gt; handleClick(index)}<br>                    style={{ cursor: &#39;pointer&#39;, color: index &lt; rating ? &#39;gold&#39; : &#39;grey&#39; }}<br>                &gt;<br>                    ★<br>                &lt;/span&gt;<br>            ))}<br>        &lt;/div&gt;<br>    );<br>};<br><br>export default StarRating;</pre><p>In this basic component, you’re rendering a series of stars based on the totalStars prop. You’re using the state to keep track of the current rating and update it when a star is clicked. Each star&#39;s color changes based on whether it’s part of the current rating.</p><h4>Making the Component Reusable</h4><p>Now that you have a basic component, let’s make it more reusable. You want to ensure it’s easy to integrate into different parts of your application with minimal changes. Here are a few ways to achieve that:</p><ol><li><strong>Props for Customization:</strong> Allow customization through props. This includes the total number of stars, the initial rating, star size, colors, and any other attributes you might need.</li><li><strong>Callback Functions:</strong> Implement callback functions for rating changes. This allows the parent component to handle the rating change event and perform actions like updating the server or state.</li><li><strong>Styles and Icons:</strong> Make the styles and icons easily customizable. You can achieve this by passing custom styles or even custom star icons as props.</li></ol><p>Here’s an updated version of the component with these enhancements:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>const StarRating = ({<br>    totalStars = 5,<br>    initialRating = 0,<br>    starSize = 24,<br>    activeColor = &#39;gold&#39;,<br>    inactiveColor = &#39;grey&#39;,<br>    onRatingChange = () =&gt; {}<br>}) =&gt; {<br>    const [rating, setRating] = useState(initialRating);<br><br>    const handleClick = (index) =&gt; {<br>        const newRating = index + 1;<br>        setRating(newRating);<br>        onRatingChange(newRating);<br>    };<br><br>    return (<br>        &lt;div&gt;<br>            {[...Array(totalStars)].map((star, index) =&gt; (<br>                &lt;span <br>                    key={index}<br>                    onClick={() =&gt; handleClick(index)}<br>                    style={{<br>                        cursor: &#39;pointer&#39;,<br>                        color: index &lt; rating ? activeColor : inactiveColor,<br>                        fontSize: `${starSize}px`<br>                    }}<br>                &gt;<br>                    ★<br>                &lt;/span&gt;<br>            ))}<br>        &lt;/div&gt;<br>    );<br>};<br><br>export default StarRating;</pre><p>In this enhanced version, you can customize almost every aspect of the star rating component through props. The onRatingChange prop allows you to handle the rating change event in the parent component. This makes your star rating component flexible and ready to be used anywhere in your application.</p><h4>Integrating the Component</h4><p>Integrating this reusable component into your application is a breeze. You just need to import it and pass the necessary props. Here’s an example of how you might use it in a product review component:</p><pre>import React, { useState } from &#39;react&#39;;<br>import StarRating from &#39;./StarRating&#39;;<br><br>const ProductReview = () =&gt; {<br>    const [rating, setRating] = useState(0);<br><br>    const handleRatingChange = (newRating) =&gt; {<br>        setRating(newRating);<br>        Optionally send the new rating to the server or update state<br>    };<br><br>    return (<br>        &lt;div&gt;<br>            &lt;h2&gt;Rate this product:&lt;/h2&gt;<br>            &lt;StarRating<br>                totalStars={5}<br>                initialRating={rating}<br>                starSize={32}<br>                activeColor=&quot;blue&quot;<br>                inactiveColor=&quot;lightgrey&quot;<br>                onRatingChange={handleRatingChange}<br>            /&gt;<br>            &lt;p&gt;Your rating: {rating} out of 5&lt;/p&gt;<br>        &lt;/div&gt;<br>    );<br>};<br><br>export default ProductReview;</pre><p>In this example, theProductReview component uses theStarRating component and handles the rating change event to update its state. You can easily customize the star rating component to fit different parts of your application, ensuring consistency and reusability.</p><h4>Conclusion</h4><p>Creating a reusable star rating component in React can greatly enhance the flexibility and maintainability of your application. By starting with a basic component and gradually adding customization options, you can build a powerful and flexible tool that can be used across different parts of your app. Remember to keep the user experience in mind by making the component intuitive and accessible. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96aa44a26ba6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Guide to Integrating expo-google-fonts in React Native]]></title>
            <link>https://medium.com/@MohamedHNoor/a-guide-to-integrating-expo-google-fonts-in-react-native-e03f60393997?source=rss-1e15a73b51d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e03f60393997</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[fonts]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Mohamed Hassan Noor]]></dc:creator>
            <pubDate>Sat, 09 Mar 2024 16:56:50 GMT</pubDate>
            <atom:updated>2024-03-09T16:58:47.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CQ4YD4TDC0_1qxByv23LoA.gif" /></figure><p>Typography plays a crucial role in shaping the design and user experience of mobile applications. With React Native&#39;s growing popularity for creating cross-platform mobile apps, developers often seek efficient ways to integrate custom fonts into their projects. Expo Google Fonts is a package that simplifies the process of integrating Google Fonts into React Native apps developed with Expo. In this guide, we will take you through the steps to seamlessly add and use Google Fonts in your React Native projects using Expo Google Fonts.</p><h3>Why Use Google Fonts in React Native?</h3><p>Google Fonts provides a wide range of free, open-source fonts that are optimized for web use and are easily available for developers. By using Google Fonts in your React Native projects, you can improve the visual appearance of your app and customize the typography to suit your design preferences. With the help of Expo Google Fonts, the process of integrating Google Fonts becomes simple, enabling you to focus more on creating a polished user interface.</p><h3>Integrating expo-google-fonts</h3><p>To start, create a new Expo project for React Native. Then, navigate to the project directory and install all the necessary dependencies.</p><pre>npx expo install @expo-google-fonts/your-font-name expo-font<br>// example: npx expo install @expo-google-fonts/lato expo-font</pre><p>Replace &#39;your-font-name&#39; with the name of the Google Font you wish to use. You can find the available font options on the Google Fonts website.</p><h3>Importing and Loading Fonts</h3><p>After installing the package, you can import and load the desired font within your React Native components by importing the necessary modules at the top of your file.</p><pre>import React from &#39;react&#39;;<br>import { Text, View, StyleSheet } from &#39;react-native&#39;;<br>import { useFonts } from &#39;@expo-google-fonts/your-font-name&#39;;<br>// example: import {  useFonts, Lato_400Regular } from &#39;@expo-google-fonts/lato&#39;;<br></pre><p>In the component function, load the font using the useFonts hook:</p><pre>const YourComponent = () =&gt; {<br>  const [fontsLoaded] = useFonts({<br>    Lato_400Regular,<br>  });<br><br>  if (!fontsLoaded) {<br>    return null;<br>  }<br><br>return (<br>    &lt;View style={styles.container}&gt;<br>      &lt;Text style={styles.text}&gt;Lato Regular&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}<br><br>export default YourComponent;<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1, <br>    justifyContent: &#39;center&#39;, <br>    alignItems: &#39;center&#39;<br>  },<br>  text: {<br>    fontFamily: &#39;Lato_400Regular&#39;, <br>    fontSize: 40,<br>    color: &quot;blue&quot;<br>  }<br>})</pre><p>Replace &#39;Lato_400Regular&#39; with the appropriate font family name and style of your choice. You can include multiple font styles within the useFonts hook for variants like bold or italic.</p><h3>Test Your Implementation</h3><p>Once you have integrated the font into your components, proceed to run your React Native project.</p><pre>yarn/npm start or expo start</pre><p>Ensure that your app loads without any errors and displays the text using the specified Google Font. You can adjust the font size, color, and other styles as needed to achieve the desired look.</p><h3>Conclusion</h3><p>Integrating Google Fonts into your React Native projects with expo-google-fonts offers a straightforward and efficient way to enhance typography and design aesthetics. By following the steps outlined in this guide, you can seamlessly incorporate custom fonts into your mobile applications, providing a visually appealing and cohesive user experience. Experiment with different fonts and styles to find the perfect combination that aligns with your app&#39;s branding and design goals. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e03f60393997" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the N+1 Query Problem in Ruby on Rails]]></title>
            <link>https://medium.com/@MohamedHNoor/understanding-the-n-1-query-problem-in-ruby-on-rails-dedd58b4439f?source=rss-1e15a73b51d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/dedd58b4439f</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[database-query]]></category>
            <category><![CDATA[database-optimization]]></category>
            <category><![CDATA[activerecord]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Mohamed Hassan Noor]]></dc:creator>
            <pubDate>Mon, 06 Nov 2023 11:58:49 GMT</pubDate>
            <atom:updated>2023-11-06T11:58:49.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="N+1 Query Problem" src="https://cdn-images-1.medium.com/max/1024/1*vUNUqQQv35KJPD7iUw6KUw.jpeg" /></figure><p>When developing web applications, efficient database querying is crucial for maintaining optimal performance. One common stumbling block that developers encounter is the N+1 query problem. In this article, we will delve into what the N+1 query problem is, its impact on application performance, and effective strategies to solve it in the context of Ruby on Rails.</p><p>The N+1 query problem is a performance issue that arises when querying related data in a database-driven application. It occurs when an initial query (the “1” in N+1) fetches a set of records, and subsequent queries are made to retrieve related data for each record individually (the “N” in N+1). This leads to a cascade of queries, which can result in a significant increase in the number of database hits.</p><p>The N+1 query problem can have a substantial impact on the performance of your Ruby on Rails application. Here are some of the consequences:</p><p>Slower Response Times:</p><ul><li>As the number of queries increases linearly with the number of records retrieved, response times can become sluggish, leading to a poor user experience.</li></ul><p>Database Overhead:</p><ul><li>Each query involves communication between the application server and the database, incurring overhead in terms of network latency and processing time.</li></ul><p>Resource Consumption:</p><ul><li>The increased number of database queries can put a strain on server resources, potentially leading to scalability issues.</li></ul><p>Reduced Scalability:</p><ul><li>In scenarios where the application experiences a surge in traffic, the N+1 query problem can exacerbate performance bottlenecks, making it difficult to scale effectively.</li></ul><p>How to Solve the N+1 Query Problem:</p><p>Eager Loading:</p><ul><li>Eager loading is a technique in Ruby on Rails that allows you to fetch associated records in a single query, rather than making separate queries for each association. This is achieved using methods like includes, joins, and preload when querying the initial set of records.</li></ul><pre>@posts = Post.includes(:comments)</pre><p>Using Scopes:</p><ul><li>Scopes in Rails allow you to encapsulate commonly used queries in your models. By defining scopes for associations, you can ensure that related data is loaded efficiently when querying.</li></ul><pre>class Post &lt; ApplicationRecord<br>  has_many :comments<br><br>  scope :with_comments, -&gt; { includes(:comments) }<br>end</pre><p>Leveraging pluck and pluck_to_hash:</p><ul><li>The pluck and pluck_to_hash methods allow you to retrieve specific columns from the database efficiently, avoiding the overhead of loading entire ActiveRecord objects.</li></ul><pre>@user_ids = Comment.pluck(:user_id)</pre><p>The N+1 query problem is a common pitfall in database-driven applications, but with a solid understanding and the right techniques, you can mitigate its impact on your Ruby on Rails projects. By employing eager loading, using scopes, and judiciously leveraging methods, you can ensure your application performs optimally even as it deals with large datasets and complex relationships. Remember, a well-optimized database query can make all the difference in delivering a seamless user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dedd58b4439f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Fix The “useEffect must not return anything besides a function” Warning in React…]]></title>
            <link>https://medium.com/@MohamedHNoor/how-to-fix-the-useeffect-must-not-return-anything-besides-a-function-warning-in-react-98cee5b73cd5?source=rss-1e15a73b51d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/98cee5b73cd5</guid>
            <category><![CDATA[code-newbie]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[microverse]]></category>
            <dc:creator><![CDATA[Mohamed Hassan Noor]]></dc:creator>
            <pubDate>Fri, 10 Feb 2023 07:54:37 GMT</pubDate>
            <atom:updated>2023-02-10T08:00:11.681Z</atom:updated>
            <content:encoded><![CDATA[<h3>How To Fix The “useEffect must not return anything besides a function” Warning in React Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wvVYNPWKzZItKwwDC2AXNw.png" /></figure><p>If you have been working with React, you may have encountered the “useEffect must not return anything besides a function” warning. This warning occurs when the return value of the useEffect hook is not a function. A useEffect hook is a powerful tool that allows you to run side effects when a component is rendered, updated, or unmounted. The purpose of the warning is to prevent accidental memory leaks and improve performance. In this article, we will discuss how to fix the “useEffect must not return anything besides a function” warning.</p><p>The useEffect hook is a simple and powerful tool, but it has a few rules that must be followed. One of these rules is that the useEffect hook must return a function. This function will be called when the component is unmounted, and it should clean up any side effects that were created.</p><p>If you are getting the “useEffect must not return anything besides a function” warning, it means that you have returned something other than a function from your useEffect hook. To fix this issue, you need to make sure that the return value of the useEffect hook is a function.</p><p>Here is an example of a useEffect hook that returns a function:</p><pre>useEffect(() =&gt; {<br>  console.log(&quot;Component rendered&quot;);<br>  return () =&gt; {<br>    console.log(&quot;Component unmounted&quot;);<br>  };<br>}, []);</pre><p>In this example, the useEffect hook is running when the component is rendered, and it logs a message to the console. The return value of the useEffect hook is a function that will be called when the component is unmounted. This function will log a message to the console, indicating that the component has been unmounted.</p><p>It’s important to note that the return value of the useEffect hook is only called when the component is unmounted. If you don’t need to clean up any side effects, you can return an empty function:</p><pre>useEffect(() =&gt; {<br>  console.log(&quot;Component rendered&quot;);<br>  return () =&gt; {};<br>}, []);</pre><p>In conclusion, the “useEffect must not return anything besides a function” warning is a reminder to follow the rules of the useEffect hook. By returning a function from the useEffect hook, you can ensure that any side effects are cleaned up properly, improving performance and preventing memory leaks. By following this simple rule, you can avoid the warning and make the most of the useEffect hook in your React applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98cee5b73cd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the biggest non-technical lesson that you have learned in your journey as a developer?]]></title>
            <link>https://medium.com/@MohamedHNoor/what-is-the-biggest-non-technical-lesson-that-you-have-learned-in-your-journey-as-a-developer-8f73c965f3b1?source=rss-1e15a73b51d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f73c965f3b1</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Mohamed Hassan Noor]]></dc:creator>
            <pubDate>Fri, 27 Jan 2023 08:30:40 GMT</pubDate>
            <atom:updated>2023-01-27T08:30:40.508Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cpRbrPvOCL4a7r8a" /><figcaption>Photo by <a href="https://unsplash.com/@cwmonty?utm_source=medium&amp;utm_medium=referral">Chris Montgomery</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As a software developer, one of the non-technical lessons that I have learned is the importance of clear communication and collaboration. it’s easy to get caught up in the technical aspects of a project and forget about the importance of effective communication and teamwork. However, these non-technical skills are essential for the success of any project.</p><p>Clear communication is crucial when working with other developers on a team. As a developer, it’s important to be able to clearly articulate technical concepts to non-technical individuals, in order to ensure that everyone is on the same page and that any misunderstandings are resolved quickly. Additionally, being able to understand and incorporate feedback and requirements from others is essential for the success of any project.</p><p>Collaboration is another important aspect of a developer’s work. Working effectively with others is essential for completing a project on time. Collaboration can take many forms, from pair programming and code reviews to working with a coding partner to define requirements and prioritize features.</p><p>In conclusion, clear communication and collaboration are essential non-technical skills for developers. They help to ensure that projects are completed on time. So, next time when you are working on a project, don’t forget to pay attention to your communication and collaboration skills, they will help you achieve your goals more easily.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f73c965f3b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>