<?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 Shravan Meena on Medium]]></title>
        <description><![CDATA[Stories by Shravan Meena on Medium]]></description>
        <link>https://medium.com/@shravanmeena?source=rss-1e1d8ba63244------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LtvR4VV9AkpfYNOPbC4g6A.jpeg</url>
            <title>Stories by Shravan Meena on Medium</title>
            <link>https://medium.com/@shravanmeena?source=rss-1e1d8ba63244------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:30:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shravanmeena/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[Using Absolute Paths in React Native]]></title>
            <link>https://shravanmeena.medium.com/using-absolute-paths-in-react-native-820d6a927a6e?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/820d6a927a6e</guid>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 22:17:07 GMT</pubDate>
            <atom:updated>2023-06-30T22:27:25.758Z</atom:updated>
            <content:encoded><![CDATA[<p>In React Native, you can use absolute paths to import modules and files instead of relative paths. Absolute paths allow you to reference files and modules from any location in your project without specifying the relative path from the current file. This can make your code more readable and maintainable.</p><p><strong>What we want to achieve?</strong></p><pre>//  😏<br>import {TBCard} from &#39;../../../../../components&#39;;<br><br>// 🙂 <br>import {TBCard} from &#39;@components&#39;;<br><br>// and you can remove @ also and replace @ something you want</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*yCkRtMrkwST53HllJYgSnw.gif" /></figure><p>To set up absolute paths in React Native, you need to configure your project to support it. Here’s a step-by-step guide on how to do that:</p><ol><li><strong>How?</strong></li></ol><pre>npm install --save-dev babel-plugin-module-resolver<br>// or<br>yarn add --dev babel-plugin-module-resolver<br><br>// I am using babel-plugin-module-resolver version (5.0.0)</pre><p>2. Create a <strong>jsconfig.json</strong> file in the root of your project.</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;src/*&quot;: [&quot;./src/*&quot;],<br>      &quot;assets/*&quot;: [&quot;./src/assets/*&quot;],<br>      &quot;components/*&quot;: [&quot;./src/components/*&quot;],<br>      &quot;constants/*&quot;: [&quot;./src/constants/*&quot;],<br>      &quot;helpers/*&quot;: [&quot;./src/helpers/*&quot;],<br>      &quot;hooks/*&quot;: [&quot;./src/hooks/*&quot;],<br>      &quot;navigation/*&quot;: [&quot;./src/navigation/*&quot;],<br>      &quot;redux/*&quot;: [&quot;./src/redux/*&quot;],<br>      &quot;screens/*&quot;: [&quot;./src/screens/*&quot;],<br>      &quot;theme/*&quot;: [&quot;./src/theme/*&quot;],<br>      &quot;utils/*&quot;: [&quot;./src/utils/*&quot;],<br>    }<br>  }<br>}</pre><p>The &quot;baseUrl&quot; option specifies the base directory for resolving absolute paths. In this example, we set it to &quot;.&quot;, assuming your source code is located in the src directory. Adjust the value according to your project&#39;s structure.</p><p>3. Create a <strong>babel.config.js</strong> file in the root of your project.</p><pre>module.exports = {<br>  plugins: [<br>    [<br>      &#39;module-resolver&#39;,<br>      {<br>        alias: {<br>          src: &#39;./src&#39;,<br>          &#39;@assets&#39;: &#39;./src/assets&#39;,<br>          &#39;@components&#39;: &#39;./src/components&#39;,<br>          &#39;@constants&#39;: &#39;./src/constants&#39;,<br>          &#39;@helpers&#39;: &#39;./src/helpers&#39;,<br>          &#39;@hooks&#39;: &#39;./src/hooks&#39;,<br>          &#39;@models&#39;: &#39;./src/models&#39;,<br>          &#39;@navigation&#39;: &#39;./src/navigation&#39;,<br>          &#39;@redux&#39;: &#39;./src/redux&#39;,<br>          &#39;@screens&#39;: &#39;./src/screens&#39;,<br>          &#39;@services&#39;: &#39;./src/services&#39;,<br>          &#39;@theme&#39;: &#39;./src/theme&#39;,<br>          &#39;@utils&#39;: &#39;./src/utils&#39;,<br>        },<br>      },<br>    ],<br>  ],<br>};</pre><p>4. <strong>Clean your cache</strong></p><p>Please do not forgot to clear your cache and please restart metro bundler for ignore any error.It will works like charm!!</p><pre>npx react-native start --reset-cache</pre><p>5. <strong>Yo! It’s time to use</strong></p><pre>import {ScreensName} from &#39;@constants/NavigationConstants&#39;;<br>import {HomeScreen, LandingScreen, TaskDetailsScreen} from &#39;@screens&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*f6c1VlwzsH9dpm1KHHgphA.gif" /></figure><p>By using absolute paths, you can import files and modules across your project more easily, regardless of the file’s location. It can simplify your import statements and help avoid confusion when dealing with complex file hierarchies.</p><h3><strong>Keep Coding!</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=820d6a927a6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why is documentation important?]]></title>
            <link>https://shravanmeena.medium.com/why-is-documentation-important-f4e98138e7c8?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4e98138e7c8</guid>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 16:49:23 GMT</pubDate>
            <atom:updated>2023-06-28T16:49:23.780Z</atom:updated>
            <content:encoded><![CDATA[<p>Why is documentation important? <a href="https://emojipedia.org/thinking-face/">🤔</a></p><p>Nowadays, many developers write code but do not like to document their code or the features they build.<br>First of all, as a developer, you should write documentation. Why?</p><p>Allow me to explain. Last month, I was working on a project where I was using the latest version of AntD. Let me explain what AntD is. Ant Design is a ReactJS UI library that contains easy-to-use components useful for building interactive user interfaces. So, while using AntD, everything was going well until I needed to use the Drawer component to display something, but I couldn’t get it to work. I followed the documentation, tried multiple times, but still couldn’t show the drawer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*fGM1mzOAhpFQI4K4uOfaPg.gif" /></figure><p>Frustrated, I decided to create my own custom drawer, which I successfully implemented. However, it made me question why I was using AntD in the first place. The whole purpose was to utilize their built-in components and make my life easier. So, I revisited the documentation and attempted the same steps again, but I still couldn’t achieve the desired result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*eiZJsHGNz9Eq7esonUG9lA.gif" /></figure><p>At this point that I realized something was wrong with the documentation. I asked to one of my best friends, Stack Overflow, for help. And guess what I found? AntD had updated the props, which was not mentioned in the documentation. They had mentioned using the ‘open’ prop to hide or display the drawer, but in reality, the prop was ‘visible.’ Now, it should make sense to you why documentation is important, not only for the developer who writes the code but also for other developers who want to use the code.</p><p>I will provide screenshots below to illustrate my point. Therefore, I strongly recommend you to write proper documentation for your code and consider explaining your code with comments if you believe certain parts may be difficult for others to understand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*W5K_0A-h4wB-EmqrKmeNag.png" /><figcaption>WRONG DOCUMENTATION (AntD Doc)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*ZF8MYQDvi3r3IUbqUq4kPg.png" /><figcaption>GOOD CODE (StackOverflow)</figcaption></figure><p>I encourage you to write documentation and include comments in your code to become a great developer.</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4e98138e7c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-Step Guide to Generating a Signed APK in React Native Using Android Studio and Terminal]]></title>
            <link>https://shravanmeena.medium.com/step-by-step-guide-to-generating-a-signed-apk-in-react-native-using-android-studio-and-terminal-5e079dc587e7?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e079dc587e7</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[signed-apk]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 15:36:19 GMT</pubDate>
            <atom:updated>2023-06-07T16:51:39.179Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you ready to unleash your amazing React Native app on the Google Play Store? 📱💥 The process of publishing an app can seem daunting, but fear not! In this guide, we will walk you through each step, providing clear instructions and commands to ensure a successful journey. Let’s dive in and make your app shine on the Google Play Store! 🚀🌟</p><p>Step 1: Generating an Upload Key 🗝️ First things first, let’s generate a private signing key using the keytool utility. This key will be used to sign your app before uploading it to Google Play. Depending on your operating system, use the appropriate command below:</p><p>Windows:</p><pre>keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000</pre><p>macOS:</p><pre>sudo keytool -genkey -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000</pre><p>Remember to keep your keystore file private and secure! 🤫🔒</p><p><em>Copy your “my-upload-key.keystore” file and move it into the “/android” directory, follow these steps:</em></p><ol><li><em>Locate your “my-upload-key.keystore” file in the directory where you generated it.</em></li><li><em>Copy the file to your clipboard.</em></li><li><em>Open the file explorer or terminal and navigate to your React Native project’s root directory.</em></li><li><em>Inside the root directory, you’ll find the “android” folder.</em></li><li><em>Paste the “my-upload-key.keystore” file into the “android” folder.</em></li></ol><p><em>By moving the “my-upload-key.keystore” file into the “/android” directory, you ensure that it is in the correct location for signing your app during the build process.</em></p><p>Step 2: Setting up Gradle Variables 📝 Now, let’s configure Gradle to use your upload key. Locate the gradle.properties file in your project directory and add the following lines, replacing the placeholders with your actual key details:</p><pre>MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore<br>MYAPP_UPLOAD_KEY_ALIAS=my-key-alias<br>MYAPP_UPLOAD_STORE_PASSWORD=*****<br>MYAPP_UPLOAD_KEY_PASSWORD=*****</pre><p>By adding these variables, Gradle will know how to sign your app during the build process.</p><p>Step 3: Adding Signing Config to Gradle ✍️✨ To ensure that your release build is signed correctly, open the android/app/build.gradle file and add the signing configuration inside the android block. Use the following code snippet:</p><pre>android {<br>    // ...<br>    signingConfigs {<br>        release {<br>            if (project.hasProperty(&#39;MYAPP_UPLOAD_STORE_FILE&#39;)) {<br>                storeFile file(MYAPP_UPLOAD_STORE_FILE)<br>                storePassword MYAPP_UPLOAD_STORE_PASSWORD<br>                keyAlias MYAPP_UPLOAD_KEY_ALIAS<br>                keyPassword MYAPP_UPLOAD_KEY_PASSWORD<br>            }<br>        }<br>    }<br>    buildTypes {<br>        release {<br>            // ...<br>            signingConfig signingConfigs.release<br>        }<br>    }<br>}</pre><p>Step 4: Generating the Release AAB or APK 🚀🎁 Now, it’s time to generate the release APK using Android Studio’s terminal. Follow the steps below:</p><ol><li>Open Android Studio.</li><li>In the toolbar at the bottom, click on “Terminal” to open the terminal window.</li><li>Navigate to the project’s root directory using the cd command.</li><li>Run the following command to generate the release APK:</li></ol><pre>./gradlew assembleRelease</pre><blockquote>Wait for the build process to complete. Once finished, you’ll find the generated APK file in the android/app/build/outputs/apk/release directory.</blockquote><p>Step 5: Testing the Release Build ✅🔍</p><p>Before submitting your app to the Google Play Store, it’s crucial to test the release build thoroughly. Uninstall any previous versions of the app from your device and then install the release build using the following command in the project root:</p><pre>npx react-native run-android --variant=release</pre><p>Make sure to terminate any running bundler instances, as all the necessary JavaScript code is bundled in the APK or AAB.</p><p>Step 6: Publishing to the Google Play Store 🌐📲 The moment has arrived! Head over to the <a href="https://play.google.com/apps/publish/">Google Play Console</a> and follow these steps:</p><ol><li>Create a new application listing.</li><li>Provide captivating app descriptions and engaging screenshots.</li><li>Upload your release AAB or APK file.</li><li>Fill in the necessary details, such as pricing and distribution options.</li><li>Review all the information carefully and hit that “Publish” button!</li></ol><p>Congratulations! Your app is now on its way to reaching millions of Android users on the Google Play Store. 🚀🌍🎉</p><p>Conclusion: Publishing your React Native app on the Google Play Store is an exciting milestone on your app development journey. By following these step-by-step instructions and using the provided commands, you can confidently navigate the publishing process. Embrace the opportunity to share your app with the world and watch it thrive in the Android ecosystem! 📲🌟🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e079dc587e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering Position & Named Arguments in JavaScript: A Beginner’s Guide ]]></title>
            <link>https://shravanmeena.medium.com/mastering-position-named-arguments-in-javascript-a-beginners-guide-e27df16145d5?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/e27df16145d5</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Tue, 06 Jun 2023 07:57:24 GMT</pubDate>
            <atom:updated>2023-06-06T07:57:24.198Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript is a versatile and powerful programming language that allows developers to create dynamic and interactive web applications. As a beginner, you may have come across the terms “position arguments” and “named arguments” while diving into the world of JavaScript functions. Fear not, my friend, for in this article, we shall demystify these concepts with the examples. So, fasten your seatbelts, and let’s embark on this adventurous journey together! 🚀</p><h3><strong>Position Arguments: The Classic Unnamed Heroes 🦸‍♀️</strong></h3><p>Imagine a scenario where you have a function that calculates the area of a rectangle. Traditionally, you would pass the length and width of the rectangle as arguments in a particular order. These arguments are known as “position arguments” since their values are assigned based on their position in the argument list.</p><pre>function calculateRectangleArea(length, width) {<br>  return length * width;<br>}<br><br>const area = calculateRectangleArea(5, 10);<br>console.log(area); // Output: 50</pre><p>In the example above, we provide the length as the first argument and the width as the second argument. The function performs its magic and returns the area of the rectangle, which we assign to the area variable. Voilà! We have our desired result.</p><h3>Named Arguments: Bringing Order to the Chaos 📝</h3><p>Sometimes, it can be confusing to remember the order of arguments, especially when functions accept multiple parameters. To alleviate this confusion, JavaScript introduced the concept of “named arguments.” Instead of relying on the position of the arguments, we can explicitly assign values to parameters using their names.</p><pre>function calculateRectangleArea({ length, width }) {<br>  return length * width;<br>}<br><br>const area = calculateRectangleArea({ length: 5, width: 10 });<br>console.log(area); // Output: 50</pre><p>In this example, we define a single argument using object destructuring. By passing an object with named properties length and width, we assign the corresponding values directly. This approach adds clarity and readability to our code, making it easier to understand the purpose of each argument.</p><h3>Position Arguments vs. Named Arguments: A Battle of Titans ⚔️</h3><p>Now, you might be wondering, “Which approach should I use? Position arguments or named arguments?” Well, dear developer, the choice depends on the situation. Position arguments are handy when the order of arguments is intuitive, and you don’t mind keeping track of their positions. On the other hand, named arguments shine when you have complex functions with numerous parameters or when you want to make your code more self-explanatory.</p><p>Allow me to demonstrate:</p><pre>function greet(firstName, lastName) {<br>  return `Hello, ${firstName} ${lastName}!`;<br>}<br><br>console.log(greet(&#39;John&#39;, &#39;Doe&#39;)); // Output: Hello, John Doe!<br><br>console.log(greet({ firstName: &#39;John&#39;, lastName: &#39;Doe&#39; })); // Output: Hello, [object Object] [object Object]!</pre><p>In the first example, we use position arguments, passing the first name and last name in the expected order. It works perfectly, and we receive a warm greeting. However, in the second example, we accidentally pass an object as an argument, resulting in a less-than-desirable greeting. Named arguments come to the rescue by providing clarity and avoiding such mishaps:</p><pre>function greet({ firstName, lastName }) {<br>  return `Hello, ${firstName} ${lastName}!`;<br>}<br><br>console.log(greet({ firstName: &#39;John&#39;, lastName: &#39;Doe&#39; })); // Output: Hello, John Doe!<br><br>console.log(greet(&#39;John&#39;, &#39;Doe&#39;)); // Output: Hello, undefined undefined!</pre><p>In this revised version, we explicitly state that the greet function expects an object with firstName and lastName properties. Hooray! Our greeting is once again delightful.</p><p>So, dear beginner developer, remember to choose your arguments wisely, based on the complexity and readability of your code. Both position arguments and named arguments are powerful tools that can make your life easier.</p><p>Now, armed with the knowledge of position and named arguments, you’re ready to conquer new programming challenges with confidence. May your code always be bug-free and your functions be filled with joyous laughter! 😄✨</p><h3>Happy coding! 🎉</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e27df16145d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leverage the Power of JavaScript’s Built-in Methods for Efficient Development ✨]]></title>
            <link>https://shravanmeena.medium.com/leverage-the-power-of-javascripts-built-in-methods-for-efficient-development-aefcd45ad017?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/aefcd45ad017</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Sun, 04 Jun 2023 18:50:16 GMT</pubDate>
            <atom:updated>2023-06-04T18:50:16.546Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript has become the 💪 powerhouse of web development, enabling developers to create dynamic and interactive websites. One of the reasons behind its popularity is the vast array of built-in methods that it offers. These methods provide developers with powerful tools to manipulate data, perform calculations, handle arrays and strings, and much more. By leveraging these built-in methods, developers can significantly enhance their productivity and create efficient and maintainable code. 🛠️💻</p><p>🔍 One of the most prominent benefits of using JavaScript’s built-in methods is the ability to write concise and expressive code. Instead of reinventing the wheel and writing complex algorithms from scratch, developers can rely on these methods to handle common tasks. This not only saves time ⌛ but also reduces the chances of introducing bugs or errors. JavaScript’s built-in methods have been optimized for performance and are often more efficient than custom implementations. ⚡💡</p><p>📚 Let’s explore some of the key categories of built-in methods in JavaScript:</p><p>1️⃣ Array Manipulation: JavaScript provides an extensive set of methods for working with arrays. From adding and removing elements to sorting, filtering, and mapping arrays, these methods allow developers to perform various operations with ease. The array methods such as `map()`, `filter()`, `reduce()`, and `forEach()` enable developers to iterate over arrays and manipulate their contents efficiently. 📊🔄</p><p>2️⃣ String Manipulation: JavaScript’s built-in methods for string manipulation are incredibly powerful. With methods like `split()`, `substring()`, `replace()`, and `trim()`, developers can easily extract substrings, replace characters or patterns, and manipulate strings according to their requirements. These methods greatly simplify tasks that would otherwise involve complex string parsing or regular expressions. 🔤🔀</p><p>3️⃣ Math Operations: JavaScript offers a rich set of mathematical functions through its built-in `Math` object. Whether it’s calculating logarithms, generating random numbers, rounding values, or performing trigonometric calculations, the `Math` object provides a wide range of methods. These methods save developers from implementing complex mathematical operations manually, allowing them to focus on other aspects of their code. 🧮🔢</p><p>4️⃣ Date and Time Manipulation: Manipulating dates and working with time is a common requirement in web development. JavaScript’s built-in `Date` object comes with a comprehensive set of methods for performing operations such as date parsing, formatting, arithmetic, and comparison. The `Date` object simplifies tasks related to date and time, ensuring accuracy and consistency across different platforms. 📅⌚</p><p>5️⃣ Regular Expressions: Regular expressions are powerful tools for pattern matching and string manipulation. JavaScript supports regular expressions through its built-in `RegExp` object and related methods. Developers can use these methods to search for patterns, validate inputs, extract data, and replace text efficiently. Regular expressions provide a flexible and concise way to work with complex string patterns, saving developers from writing extensive code for pattern matching. 🔍🔧</p><p>By utilizing these built-in methods effectively, developers can improve code readability, maintainability, and performance. Understanding the capabilities and proper usage of these methods allows developers to write clean and concise code that is easier to understand and debug. It also promotes code reusability, as these methods can be employed across different projects. 📝✨</p><p>However, it’s important to note that while JavaScript’s built-in methods are incredibly powerful, they may not always be the most performant solution for every scenario. Depending on the specific requirements and performance considerations, developers should evaluate the trade-offs between using built-in methods and implementing custom solutions. ⚖️⚙️</p><p>In conclusion, JavaScript’s built-in methods provide a treasure trove of functionality for developers. Leveraging these methods enables efficient and streamlined development by reducing code complexity and enhancing productivity. By mastering these built-in methods and understanding their application, developers can harness the true power of JavaScript and build robust and scalable applications. So, dive into the documentation, explore the vast array of methods, and unleash your coding superpowers! 💪💻✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aefcd45ad017" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comprehensive Guide: How to Delete All Existing GitHub Accounts on Mac]]></title>
            <link>https://shravanmeena.medium.com/comprehensive-guide-how-to-delete-all-existing-github-accounts-on-mac-d2f6f118443a?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2f6f118443a</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Sun, 28 May 2023 10:12:44 GMT</pubDate>
            <atom:updated>2023-05-28T10:12:44.845Z</atom:updated>
            <content:encoded><![CDATA[<p>To delete all existing GitHub accounts on your Mac, you need to remove the associated SSH keys and configuration files. Here’s a step-by-step guide:</p><h3>Step 1: Remove SSH keys</h3><ol><li>Open Terminal on your Mac.</li><li>Navigate to the SSH directory by running the following command and pressing Enter</li></ol><pre>cd ~/.ssh</pre><p>3. List the SSH key files in the directory by running the command:</p><pre>ls</pre><p>4. Identify the SSH key files associated with your GitHub accounts. Typically, they have names like id_rsa and id_rsa.pub.</p><p>5. To remove a specific SSH key file, use the following command:</p><pre>rm &lt;key_file&gt;</pre><p>Replace &lt;key_file&gt; with the filename of the SSH key you want to delete.</p><ol><li>Repeat step 5 for each SSH key file associated with your GitHub accounts.</li></ol><h3>Step 2: Remove SSH configuration file</h3><ol><li>Open Terminal on your Mac.</li><li>Navigate to the SSH directory by running the following command and pressing Enter:</li></ol><pre>cd ~/.ssh</pre><p>3. Delete the SSH configuration file by running the command:</p><pre>rm config</pre><p>By following these steps, you can remove all existing GitHub accounts from your Mac, including the associated SSH keys and configuration files. It’s important to note that deleting the SSH keys and configuration files will also prevent you from accessing those GitHub accounts on your Mac in the future. If you plan to continue using any of the accounts, make sure to back up the SSH keys and configuration files before deleting them.</p><h3>Note:<br>Beginner’s Guide: How to Manage Multiple GitHub Accounts on Mac⚡️</h3><p><a href="https://medium.com/@shravanmeena/beginners-guide-how-to-manage-multiple-github-accounts-on-mac-9d52f0ee5864">https://medium.com/@shravanmeena/beginners-guide-how-to-manage-multiple-github-accounts-on-mac-9d52f0ee5864</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2f6f118443a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginner’s Guide: How to Manage Multiple GitHub Accounts on Mac]]></title>
            <link>https://shravanmeena.medium.com/beginners-guide-how-to-manage-multiple-github-accounts-on-mac-9d52f0ee5864?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d52f0ee5864</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Sun, 28 May 2023 10:06:57 GMT</pubDate>
            <atom:updated>2023-07-05T11:42:48.577Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong>:</h3><p>Managing multiple GitHub accounts on your Mac can be a valuable skill, especially if you work on different projects or contribute to various open-source communities. However, navigating between accounts can seem daunting for beginners. In this step-by-step guide, we’ll walk you through the process of setting up and managing multiple GitHub accounts on your Mac, making it beginner-friendly with clear examples.</p><h3><strong>Step 1: Set up SSH keys</strong></h3><ol><li>Open Terminal on your Mac. You can find it by going to “Applications” &gt; “Utilities” &gt; “Terminal”.</li><li>To check if you already have SSH keys, type the following command and press Enter:</li></ol><pre>ls -al ~/.ssh</pre><p>3. If you see files named id_rsa and id_rsa.pub in the output, you already have SSH keys, and you can skip to Step 2. Otherwise, generate a new SSH key by running this command and pressing Enter:.</p><pre>ssh-keygen -t rsa -C &quot;your_email@example.com&quot;</pre><p><strong>Note</strong>: Replace &quot;your_email@example.com&quot; with the email address associated with your GitHub account.</p><p>4. You&#39;ll be prompted to choose a file path to save the SSH key. Press Enter to accept the default path (or change the file name `/Users/{your_username}/.ssh/custom_name`).</p><p>5. You&#39;ll also be asked to enter a passphrase. It&#39;s optional but recommended for added security.</p><p>6. Repeat steps 2-5 if you want to set up SSH keys for your other GitHub accounts.</p><h3>VIDEO TUTS:</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO_LbjxRG9N4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO_LbjxRG9N4&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdd373199af983277aca5a0ade24fbf6/href">https://medium.com/media/cdd373199af983277aca5a0ade24fbf6/href</a></iframe><h3><strong>Step 2: Add SSH keys to GitHub</strong></h3><p>Copy the SSH key to your clipboard by running this command and pressing Enter:</p><pre>pbcopy &lt; ~/.ssh/id_rsa.pub</pre><ol><li>Go to the GitHub website (<a href="https://github.com/">https://github.com</a>) and log in to the account for which you want to add the SSH key.</li><li>Click on your profile picture in the top-right corner and select “Settings” from the dropdown menu.</li><li>In the left sidebar, click on “SSH and GPG keys”.</li><li>Click on the green “New SSH key” button.</li><li>Give the key a descriptive title (e.g., “Mac SSH Key”) and paste the key into the “Key” field.</li><li>Click on the green “Add SSH key” button.</li><li>Repeat steps 2–7 to add SSH keys for your other GitHub accounts.</li></ol><h3><strong>Step 3: Create an SSH configuration file</strong></h3><ol><li>Open Terminal on your Mac.</li><li>Navigate to the SSH directory by running this command and pressing Enter:</li></ol><pre>cd ~/.ssh</pre><p>3. Create or edit the SSH configuration file by running this command and pressing Enter:</p><pre>touch config<br>open -e config</pre><p>4. In the text editor that opens, add the following lines for each of your GitHub accounts:</p><pre># Account 1<br>Host github.com-personal<br>  HostName github.com<br>  User git<br>  IdentityFile ~/.ssh/id_rsa<br><br># Account 2<br>Host github.com-professional<br>  HostName github.com<br>  User git<br>  IdentityFile ~/.ssh/other_key</pre><p>Note: Replace personal and professional with unique identifiers for your GitHub accounts. Replace ~/.ssh/other_key with the file path to the SSH key of the respective account.</p><p>5. Save and close the configuration file.</p><h3>Save key identities in local machine</h3><p>First, we have to remove any existing identities by running the following command.</p><pre>cd ~<br>ssh-add -D</pre><p>After delete, check if the newly added keys were saved successfully by running the following command.</p><pre>ssh-add -l</pre><p>Now you have to authenticate the keys with GitHub by running following commands.</p><pre>ssh -T github.com-personal<br>ssh -T github.com-professional</pre><p>Now, we’re almost done!</p><h3><strong>Step 4:</strong></h3><h4>For brand new Repository</h4><ol><li>Open Terminal on your Mac.</li><li>Change to the directory where you want to clone the repository. For example:</li></ol><pre>cd Documents/Projects</pre><p>3. Clone a repository using the following command and press Enter:</p><pre>git clone git@github.com-personal:username/repo.git</pre><p><strong>Note</strong>: Replace personal with the identifier for the GitHub account you want to use, username with your GitHub username, and repo with the name of the repository.</p><p>4. Repeat Step 4 for cloning repositories using your other GitHub accounts.</p><h4>For Existing Repository</h4><ol><li>First check remote of existing</li></ol><pre>git remote -v</pre><p>2. Most probably it will list you remote in format</p><pre>git@github.com:{repo-owner-name}/{repo-name}.git</pre><p>3. We have to modify this remote origin to the following format</p><pre>git remote set-url origin git@github.com-{identifier}/{repo-owner-name}/{repo-name}.git</pre><p><strong>Note</strong>: It should look like this git@github.com-personal:username/repo.git</p><h3><strong>Step 5: Configure local Git settings</strong></h3><ol><li>Open Terminal on your Mac.</li><li>Change to the directory of the cloned repository. For example:</li></ol><pre>cd Documents/Projects/repo</pre><p>3. Configure your local Git settings by running the following commands and pressing Enter after each one:</p><pre>git config user.name &quot;Your Name&quot;<br>git config user.email &quot;your_email@example.com&quot;</pre><p>Note: Replace &quot;Your Name&quot; and &quot;your_email@example.com&quot; with your desired name and email for the current GitHub account.</p><p>4. Repeat steps 2–3 for each cloned repository and GitHub account.</p><h3><strong>Step 6: Switch between GitHub accounts</strong></h3><ol><li>Open Terminal on your Mac.</li><li>Change to the directory of the cloned repository for the account you want to use.</li><li>Use the following command to switch to the desired GitHub account and press Enter:</li></ol><pre>git config user.name &quot;Your Name&quot;<br>git config user.email &quot;your_email@example.com&quot;</pre><p>Note: Replace &quot;Your Name&quot; and &quot;your_email@example.com&quot; with the name and email associated with the GitHub account you want to use.</p><p>4. Repeat steps 2–3 whenever you need to switch between GitHub accounts.</p><h3><strong>Conclusion</strong>:</h3><p>Congratulations! You have successfully learned how to manage multiple GitHub accounts on your Mac. By following these beginner-friendly steps and examples, you can seamlessly work on different projects or contribute to various open-source communities without the hassle of constantly switching accounts. Remember to switch to the appropriate account configuration when working with a specific repository to ensure correct authentication and commit attribution.</p><h3>Comprehensive Guide: How to Delete All Existing GitHub Accounts on Mac</h3><p><a href="https://shravanmeena.medium.com/comprehensive-guide-how-to-delete-all-existing-github-accounts-on-mac-d2f6f118443a">https://shravanmeena.medium.com/comprehensive-guide-how-to-delete-all-existing-github-accounts-on-mac-d2f6f118443a</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d52f0ee5864" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supercharge Your React App: Beginner-Friendly Guide to Lazy Loading with Production-Level Code ⚡️]]></title>
            <link>https://shravanmeena.medium.com/supercharge-your-react-app-beginner-friendly-guide-to-lazy-loading-with-production-level-code-7ced111a1fe?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ced111a1fe</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Sat, 27 May 2023 08:51:43 GMT</pubDate>
            <atom:updated>2023-05-28T11:00:35.770Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong>:<br>In this beginner-friendly guide, we’ll explore how to optimize your React applications using lazy loading techniques. Lazy loading allows you to improve the performance and user experience by loading components on-demand, reducing the initial bundle size and load time. We’ll walk through the implementation step-by-step, providing production-level code examples that you can easily integrate into your own projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*DXu3HFwC_a65PjqHHBeHzg.gif" /></figure><p><strong>What is Lazy Loading and Why Does it Matter?<br></strong>Lazy loading is a technique that allows us to defer the loading of certain components until they are actually needed. Rather than including all components in the initial bundle, lazy loading splits the code into smaller chunks and loads them on-demand. This significantly improves the initial load time and overall performance of your React application.</p><p><strong>Prerequisites:<br></strong>To follow along, ensure you have <a href="https://nodejs.org/en/download"><em>Node.js</em></a> and npm (Node Package Manager) installed on your machine.</p><p><strong>Setting Up a React Project:<br></strong>Let’s start by creating a new React project and setting up the necessary dependencies.</p><p>Step 1: Open your terminal and run the following command to create a new React project:</p><pre>npx create-react-app lazy-loading-demo</pre><p>Step 2: Navigate to the project directory:</p><pre>cd lazy-loading-demo</pre><p>Step 3: Install the necessary dependencies:</p><pre>npm install react-router-dom</pre><p>Now that our React project is set up, let’s dive into the implementation of lazy loading.</p><p><strong>Implementing Lazy Loading: <br></strong>In this example, we’ll demonstrate lazy loading by creating a simple application with multiple routes, each having its own lazy-loaded component.</p><p>Step 1: Create a new file called Home.js in the src directory:</p><pre>// Home.js<br>import React from &#39;react&#39;;<br><br>const Home = () =&gt; {<br>  return &lt;h2&gt;Welcome to the Home page!&lt;/h2&gt;;<br>};<br><br>export default Home;</pre><p>Step 2: Create another file called About.js in the src directory:</p><pre>// About.js<br>import React from &#39;react&#39;;<br><br>const About = () =&gt; {<br>  return &lt;h2&gt;Welcome to the About page!&lt;/h2&gt;;<br>};<br><br>export default About;</pre><p>Step 3: Open the App.js file and update it as follows:</p><pre>// App.js<br>import React, { lazy, Suspense } from &#39;react&#39;;<br>import { BrowserRouter as Router, Route, Routes } from &#39;react-router-dom&#39;;<br><br>const Home = lazy(() =&gt; import(&#39;./Home&#39;));<br>const About = lazy(() =&gt; import(&#39;./About&#39;));<br><br>const App = () =&gt; {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>        &lt;Routes&gt;<br>          &lt;Route path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;<br>          &lt;Route path=&quot;/about&quot; element={&lt;About /&gt;} /&gt;<br>        &lt;/Routes&gt;<br>      &lt;/Suspense&gt;<br>    &lt;/Router&gt;<br>  );<br>};<br><br>export default App;</pre><ul><li>In this example, we have two routes: the home route (“/”) and the about route (“/about”).</li></ul><p>Step 4: Save the changes, and start the development server:</p><pre>npm start</pre><p>Now, if you navigate to the home route (“/”) or the about route (“/about”), you’ll notice that the components are lazy-loaded on-demand, with a “Loading…” message displayed until they are fully loaded.</p><p><strong>Benefits of Lazy Loading: <br></strong>Lazy loading provides numerous benefits for React applications, even for beginners:</p><ol><li><em>Improved Performance</em>: By loading components on-demand, you reduce the initial bundle size, resulting in faster load times and improved performance.</li><li><em>Better User Experience</em>: Users experience faster page transitions and interactions as components are loaded only when needed.</li><li><em>Modular Code Structure</em>: Lazy loading encourages a modular code structure by splitting your application into smaller, more manageable chunks. This improves code maintainability and scalability.</li><li><em>Enhanced Memory Management</em>: Lazy loading helps optimize resource utilization by loading components when required, leading to efficient memory management.</li></ol><p><strong>Conclusion</strong>: <br>Lazy loading is a powerful technique to optimize your React applications, and with the step-by-step implementation provided in this article, you can easily integrate it into your own projects. By deferring the loading of non-critical components, you’ll significantly improve the performance and user experience of your React applications. Start incorporating lazy loading into your projects and witness the impact it can make on your application’s speed and responsiveness.</p><p><strong>Happy coding!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ced111a1fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Best Practices for JavaScript Naming Conventions]]></title>
            <link>https://shravanmeena.medium.com/5-best-practices-for-javascript-naming-conventions-b603431bf2d9?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/b603431bf2d9</guid>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 19:53:02 GMT</pubDate>
            <atom:updated>2023-04-20T19:53:02.212Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript is a popular programming language used for building dynamic and interactive web applications. One of the key aspects of writing maintainable and readable code in JavaScript is following best practices for naming conventions. In this article, we will discuss some of the best practices for naming conventions in JavaScript.</p><ol><li>Use descriptive names for variables and functions:</li></ol><p>Descriptive names help to make your code more readable and understandable. Use names that describe the purpose or functionality of the variable or function. Avoid using generic names like “temp” or “x” as they don’t provide any context about what the variable or function is used for.</p><p>Example:</p><p>// Bad naming convention let temp = 10; function x() {}</p><p>// Good naming convention let userAge = 10; function calculateSum() {}</p><ol><li>Use camelCase for variables and functions:</li></ol><p>In JavaScript, camelCase is the most commonly used naming convention for variables and functions. CamelCase is a naming convention where the first word is in lowercase and the subsequent words are in uppercase.</p><p>Example:</p><p>// Bad naming convention let user_age = 10; function calculate_sum() {}</p><p>// Good naming convention let userAge = 10; function calculateSum() {}</p><ol><li>Use PascalCase for constructor functions:</li></ol><p>In JavaScript, PascalCase is the naming convention used for constructor functions. PascalCase is a naming convention where the first letter of each word is in uppercase.</p><p>Example:</p><p>// Bad naming convention function user(name, age) {}</p><p>// Good naming convention function User(name, age) {}</p><ol><li>Use all-caps for constants:</li></ol><p>Constants are variables that should not be changed once they are defined. In JavaScript, constants are usually written in all uppercase letters.</p><p>Example:</p><p>// Bad naming convention const pi = 3.14;</p><p>// Good naming convention const PI = 3.14;</p><ol><li>Use meaningful names for boolean variables:</li></ol><p>Boolean variables are used to store true or false values. Use meaningful names for boolean variables that describe the condition that is being checked.</p><p>Example:</p><p>// Bad naming convention let isTrue = true;</p><p>// Good naming convention let isUserLoggedIn = true;</p><p>In conclusion, following good naming conventions is essential to write clean, readable, and maintainable code in JavaScript. By adopting these best practices, you can make your code more understandable for other developers, reduce bugs and make debugging easier, and improve the overall quality of your codebase.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b603431bf2d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Leveling Up Your React Skills in 2023: Best Practices, Tips, and Techniques for Writing…]]></title>
            <link>https://shravanmeena.medium.com/leveling-up-your-react-skills-in-2023-best-practices-tips-and-techniques-for-writing-b870ff2e1d3f?source=rss-1e1d8ba63244------2</link>
            <guid isPermaLink="false">https://medium.com/p/b870ff2e1d3f</guid>
            <category><![CDATA[shravanmeena]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Shravan Meena]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 12:26:51 GMT</pubDate>
            <atom:updated>2023-04-18T12:27:51.236Z</atom:updated>
            <content:encoded><![CDATA[<h3>🎓 Leveling Up Your React Skills in 2023: Best Practices, Tips, and Techniques for Writing High-Quality Code 🚀</h3><p>React is a popular JavaScript library for building user interfaces. Over the years, the community has developed many best practices for writing React code, which can help you write better, more efficient, and more maintainable code. In this article, we will explore some of the best practices for writing React code in 2023. Let’s dive in! 🏊‍♂️</p><p><strong>1. Use Functional Components ⚛️</strong></p><p>Functional components are a great way to write more concise and efficient code. They are also easier to test and debug. In React 16.8, the Hooks API was introduced, which allows functional components to use state and other React features. This makes functional components a viable alternative to class components.</p><p>Example:</p><pre>function MyComponent() {<br>  const [count, setCount] = useState(0);<br><br>  function handleClick() {<br>    setCount(count + 1);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>2. Use JSX for Markup 🎨</strong></p><p>JSX is a syntax extension for JavaScript that allows you to write HTML-like code in your JavaScript files. It is a great way to keep your markup and logic in the same file and allows for more readable and maintainable code.</p><p>Example:</p><pre>function MyComponent() {<br>  return (<br>    &lt;div className=&quot;container&quot;&gt;<br>      &lt;h1&gt;Hello World&lt;/h1&gt;<br>      &lt;p&gt;This is my first React component&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>3. Use Prop Types for Type Checking 🧐</strong></p><p>Prop Types are a way to define the expected types of the props passed to a component. This can help catch errors early and make your code more robust. In addition, the use of Prop Types is now an official recommendation from the React team.</p><p>Example:</p><pre>import PropTypes from &#39;prop-types&#39;;<br><br>function MyComponent(props) {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;{props.title}&lt;/h1&gt;<br>      &lt;p&gt;{props.text}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>MyComponent.propTypes = {<br>  title: PropTypes.string.isRequired,<br>  text: PropTypes.string.isRequired<br>};</pre><p><strong>4. Use State Effectively 🤖</strong></p><p>State is a powerful feature of React and should be used effectively. Here are some best practices for using state:</p><ul><li>Only use state when necessary</li><li>Use stateless components whenever possible</li><li>Avoid deeply nested state</li><li>Use the useState Hook for simple state management</li><li>Use the useReducer Hook for more complex state management</li></ul><p>Example:</p><pre>import { useState } from &#39;react&#39;;<br><br>function MyComponent() {<br>  const [count, setCount] = useState(0);<br><br>  function handleClick() {<br>    setCount(count + 1);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>5. Use the Context API for Global State 🌍</strong></p><p>The Context API is a way to share data between components without having to pass props down through every level of the component hierarchy. It is a great way to manage global state in your application.</p><p>Example:</p><pre>import { createContext, useContext } from &#39;react&#39;;<br><br>const MyContext = createContext();<br><br>function MyComponent() {<br>  return (<br>    &lt;MyContext.Provider value=&quot;Hello World&quot;&gt;<br>      &lt;ChildComponent /&gt;<br>    &lt;/MyContext.Provider&gt;<br>  );<br>}<br><br>function ChildComponent() {<br>  const value = useContext(MyContext);<br><br>  return &lt;p&gt;{value}&lt;/p&gt;;<br>}</pre><p><strong>6. Use React.memo for Performance</strong></p><p>React.memo is a higher-order component that can be used to memoize a component and prevent unnecessary re-renders. It should be used on components that are expensive to render or that don’t need to be re-rendered frequently.</p><p>Example:</p><pre>import React, { useState, memo } from &#39;react&#39;;<br><br>const MyComponent = memo(({ name }) =&gt; {<br>  console.log(&#39;rendering MyComponent&#39;);<br><br>  return &lt;p&gt;Hello, {name}!&lt;/p&gt;;<br>});<br><br>function App() {<br>  const [name, setName] = useState(&#39;&#39;);<br><br>  function handleChange(event) {<br>    setName(event.target.value);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;input type=&quot;text&quot; value={name} onChange={handleChange} /&gt;<br>      &lt;MyComponent name={name} /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>7. Use Keys in Lists 🗝️</strong></p><p>When rendering a list of items in React, it’s important to include a unique “key” prop for each item. This allows React to optimize the rendering and update only the necessary components.</p><p>Example:</p><pre>function MyComponent() {<br>  const items = [&#39;Item 1&#39;, &#39;Item 2&#39;, &#39;Item 3&#39;];<br><br>  return (<br>    &lt;ul&gt;<br>      {items.map((item, index) =&gt; (<br>        &lt;li key={index}&gt;{item}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p><strong>8. Use CSS Modules for Styling 🎨</strong></p><p>CSS Modules are a way to encapsulate CSS styles and prevent them from leaking into other components. They allow you to use class names that are unique to each component and avoid naming collisions.</p><p>Example:</p><pre>import styles from &#39;./MyComponent.module.css&#39;;<br><br>function MyComponent() {<br>  return (<br>    &lt;div className={styles.container}&gt;<br>      &lt;h1 className={styles.title}&gt;Hello World&lt;/h1&gt;<br>      &lt;p className={styles.text}&gt;This is my first React component&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>9. Use Error Boundaries for Error Handling 🚨</strong></p><p>Error boundaries are a way to handle errors in your React components and prevent the whole application from crashing. They allow you to catch errors at the component level and display a fallback UI.</p><p>Example:</p><pre>class ErrorBoundary extends React.Component {<br>  constructor(props) {<br>    super(props);<br>    this.state = { hasError: false };<br>  }<br><br>  static getDerivedStateFromError(error) {<br>    return { hasError: true };<br>  }<br><br>  render() {<br>    if (this.state.hasError) {<br>      return &lt;h1&gt;Something went wrong.&lt;/h1&gt;;<br>    }<br><br>    return this.props.children;<br>  }<br>}<br><br>function MyComponent() {<br>  const items = null;<br><br>  return (<br>    &lt;ErrorBoundary&gt;<br>      &lt;ul&gt;<br>        {items.map((item) =&gt; (<br>          &lt;li&gt;{item}&lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br>    &lt;/ErrorBoundary&gt;<br>  );<br>}</pre><p><strong>10. Use useCallback for Memoizing Callbacks 🤝</strong></p><p>useCallback is a hook that can be used to memoize a callback function and prevent unnecessary re-renders. It should be used on callbacks that are passed down as props to child components or used as dependencies in useEffect.</p><p>Example:</p><pre>import React, { useState, useCallback } from &#39;react&#39;;<br><br>function MyComponent({ onClick }) {<br>  const [count, setCount] = useState(0);<br><br>  const handleClick = useCallback(() =&gt; {<br>    setCount((prevCount) =&gt; prevCount + 1);<br>    onClick(count);<br>  }, [count, onClick]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;button onClick={handleClick}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>11. Use React.StrictMode for Debugging 🔍</strong></p><p>React.StrictMode is a component that can be used to highlight potential problems in your code during development. It enables additional checks and warnings in the console and helps you find common issues such as unintended side effects or deprecated features.</p><p>Example:</p><pre>import React from &#39;react&#39;;<br><br>function App() {<br>  return (<br>    &lt;React.StrictMode&gt;<br>      &lt;div&gt;Hello World&lt;/div&gt;<br>    &lt;/React.StrictMode&gt;<br>  );<br>}</pre><p><strong>12. Use Context API for Global State Management 🌎</strong></p><p>Context API is a way to manage global state in your React application without having to pass down props through multiple layers of components. It allows you to create a context object that can be consumed by any component in the tree.</p><p>Example:</p><pre>import React, { createContext, useContext, useState } from &#39;react&#39;;<br><br>const MyContext = createContext();<br><br>function MyProvider({ children }) {<br>  const [count, setCount] = useState(0);<br><br>  const incrementCount = () =&gt; setCount((prevCount) =&gt; prevCount + 1);<br><br>  return (<br>    &lt;MyContext.Provider value={{ count, incrementCount }}&gt;<br>      {children}<br>    &lt;/MyContext.Provider&gt;<br>  );<br>}<br><br>function MyComponent() {<br>  const { count, incrementCount } = useContext(MyContext);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;button onClick={incrementCount}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>function App() {<br>  return (<br>    &lt;MyProvider&gt;<br>      &lt;MyComponent /&gt;<br>    &lt;/MyProvider&gt;<br>  );<br>}</pre><p><strong>13. Use React.lazy and Suspense for Code Splitting 🧩</strong></p><p>React.lazy and Suspense are features that allow you to load components lazily and improve the performance of your application. They allow you to split your code into smaller chunks and load them only when they are needed.</p><p>Example:</p><pre>import React, { lazy, Suspense } from &#39;react&#39;;<br><br>const LazyComponent = lazy(() =&gt; import(&#39;./LazyComponent&#39;));<br><br>function App() {<br>  return (<br>    &lt;div&gt;<br>      &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>        &lt;LazyComponent /&gt;<br>      &lt;/</pre><p><strong>14. Use Memoization for Performance Optimization 💨</strong></p><p>Memoization is a technique that can be used to optimize performance by caching the results of expensive function calls. React provides a hook called useMemo that can be used to memoize a value and prevent unnecessary re-computations.</p><p>Example:</p><pre>import React, { useState, useMemo } from &#39;react&#39;;<br><br>function MyComponent() {<br>  const [count, setCount] = useState(0);<br><br>  const expensiveCalculation = useMemo(() =&gt; {<br>    // Expensive calculation here<br>    return count * 2;<br>  }, [count]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;p&gt;Result: {expensiveCalculation}&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount((prevCount) =&gt; prevCount + 1)}&gt;<br>        Click me<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>15. Use React Testing Library for Testing 🧪</strong></p><p>React Testing Library is a library that can be used to test your React components in a way that mimics how a user would interact with them. It encourages testing the component’s behavior rather than its implementation details.</p><p>Example:</p><pre>import React from &#39;react&#39;;<br>import { render, fireEvent } from &#39;@testing-library/react&#39;;<br>import MyComponent from &#39;./MyComponent&#39;;<br><br>test(&#39;increment count on button click&#39;, () =&gt; {<br>  const { getByText, getByTestId } = render(&lt;MyComponent /&gt;);<br><br>  expect(getByTestId(&#39;count&#39;)).toHaveTextContent(&#39;0&#39;);<br><br>  fireEvent.click(getByText(&#39;Click me&#39;));<br><br>  expect(getByTestId(&#39;count&#39;)).toHaveTextContent(&#39;1&#39;);<br>});</pre><p><strong>16. Use React Router for Routing 🛣️</strong></p><p>React Router is a library that can be used to handle client-side routing in your React application. It allows you to define routes, handle navigation, and pass parameters between components.</p><p>Example:</p><pre>import React from &#39;react&#39;;<br>import { BrowserRouter as Router, Route, Link } from &#39;react-router-dom&#39;;<br>import Home from &#39;./Home&#39;;<br>import About from &#39;./About&#39;;<br><br>function App() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;div&gt;<br>        &lt;nav&gt;<br>          &lt;ul&gt;<br>            &lt;li&gt;<br>              &lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;<br>            &lt;/li&gt;<br>            &lt;li&gt;<br>              &lt;Link to=&quot;/about&quot;&gt;About&lt;/Link&gt;<br>            &lt;/li&gt;<br>          &lt;/ul&gt;<br>        &lt;/nav&gt;<br><br>        &lt;Route exact path=&quot;/&quot; component={Home} /&gt;<br>        &lt;Route path=&quot;/about&quot; component={About} /&gt;<br>      &lt;/div&gt;<br>    &lt;/Router&gt;<br>  );<br>}</pre><p><strong>17. Use ESLint and Prettier for Code Quality 📝</strong></p><p>ESLint and Prettier are tools that can be used to ensure consistent code quality and catch potential errors before they become problems. ESLint provides a way to enforce coding standards and Prettier automatically formats your code to make it more readable.</p><p>Example:</p><pre>// .prettierrc.js<br>module.exports = {<br>  trailingComma: &#39;es5&#39;,<br>  tabWidth: 2,<br>  semi: true,<br>  singleQuote: true,<br>};</pre><p><strong>19. Use Hooks Instead of Higher-Order Components or Render Props ⚓</strong></p><p>Hooks are a more modern way to reuse stateful logic in your React components than higher-order components or render props. They allow you to encapsulate complex stateful logic into reusable functions that can be used in multiple components.</p><p>Example:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function useCounter(initialCount) {<br>  const [count, setCount] = useState(initialCount);<br><br>  function increment() {<br>    setCount((prevCount) =&gt; prevCount + 1);<br>  }<br><br>  return [count, increment];<br>}<br><br>function MyComponent() {<br>  const [count, increment] = useCounter(0);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;button onClick={increment}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>20. Use TypeScript for Type Safety 🔍</strong></p><p>TypeScript is a superset of JavaScript that adds static type checking and other features that can help you write more reliable and maintainable code. It can catch many errors at compile time and provide better documentation for your code.</p><p>Example:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>interface Props {<br>  text: string;<br>}<br><br>function MyComponent(props: Props) {<br>  const [count, setCount] = useState&lt;number&gt;(0);<br><br>  function increment() {<br>    setCount((prevCount) =&gt; prevCount + 1);<br>  }<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;{props.text}&lt;/p&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;button onClick={increment}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>21. Use Server-Side Rendering for Better Performance 🚀</strong></p><p>Server-side rendering (SSR) is a way to render your React application on the server before sending it to the client. This can result in faster initial load times, better search engine optimization, and improved accessibility for users.</p><p>Example:</p><pre>// server.js<br>import React from &#39;react&#39;;<br>import ReactDOMServer from &#39;react-dom/server&#39;;<br>import App from &#39;./App&#39;;<br><br>const html = ReactDOMServer.renderToString(&lt;App /&gt;);<br><br>console.log(html);</pre><pre>// client.js<br>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import App from &#39;./App&#39;;<br><br>ReactDOM.hydrate(&lt;App /&gt;, document.getElementById(&#39;root&#39;));</pre><p><strong>22. Use React DevTools for Debugging 🐛</strong></p><p>React DevTools is a browser extension that can help you debug your React components. It can show you the component tree, props, state, and much more.</p><p>First, make sure you have the React Developer Tools extension installed in your browser. You can download it from the Chrome Web Store or the Firefox Add-ons website.</p><p>Next, open your React application in the browser and open the Developer Tools. Click on the “React” tab to view the React Developer Tools panel.</p><p>In the React Developer Tools panel, you should see a tree of components that make up your application. You can expand and collapse the tree to navigate through the components.</p><p>You can also select a component in the tree to view its props, state, and other information. This can be useful for debugging issues with your components.</p><p>For example, let’s say you have a component that’s not rendering correctly. You can use the React Developer Tools to inspect the component and see if there are any errors or issues with its props or state.</p><p>🎉 Congratulations! You’ve made it to the end of our React Best Practices guide for 2023! 🎉</p><p>We hope that this article has provided you with valuable insights and tips to help you write better React code. By following these best practices, you can create more efficient, maintainable, and scalable React applications.</p><p>Remember to always strive for simplicity, readability, and performance in your code. Keep learning, experimenting, and exploring new techniques and tools to improve your React skills and stay up-to-date with the latest trends and best practices.</p><p>Happy coding! 💻🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b870ff2e1d3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>