<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shevon Soyza</title>
    <description>The latest articles on DEV Community by Shevon Soyza (@shevonsoyza).</description>
    <link>https://dev.to/shevonsoyza</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1138922%2F26b37c1d-8888-4804-a5f9-f2bba739a4ff.jpg</url>
      <title>DEV Community: Shevon Soyza</title>
      <link>https://dev.to/shevonsoyza</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shevonsoyza"/>
    <language>en</language>
    <item>
      <title>Exploring Lists in React Native: Choosing the Right Component</title>
      <dc:creator>Shevon Soyza</dc:creator>
      <pubDate>Mon, 21 Aug 2023 13:21:07 +0000</pubDate>
      <link>https://dev.to/shevonsoyza/exploring-lists-in-react-native-choosing-the-right-component-2lg6</link>
      <guid>https://dev.to/shevonsoyza/exploring-lists-in-react-native-choosing-the-right-component-2lg6</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;When it comes to developing user-friendly, optimised apps with the React Native framework, lists play an important role. Lists help us organise and present the information neatly in the apps. React Native offers different types of list components for different scenarios. In this article, we will discuss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FlatList&lt;/li&gt;
&lt;li&gt;SectionList&lt;/li&gt;
&lt;li&gt;ScrollView&lt;/li&gt;
&lt;li&gt;VirtualizedList&lt;/li&gt;
&lt;li&gt;GridList&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Among them, choosing the right list component will help increase the app’s performance and user experience. So, let’s take a quick look at these components.&lt;/p&gt;

&lt;h3&gt;
  
  
  FlatList: Efficient Rendering for Long Lists
&lt;/h3&gt;

&lt;p&gt;When dealing with a lengthy dataset where we need to show lots of things in order, the FlatList component is the go-to solution. Also, it has a virtualization technique that only shows what you’re looking at right now. Unlike traditional lists that render all items at once, FlatList renders only the items currently visible on the screen. This means our app will load faster and use less memory. &lt;/p&gt;

&lt;p&gt;Here's a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import {FlatList, View, Text} from 'react-native';

const data = [
  {id: '1', title: 'Item 1'},
  {id: '2', title: 'Item 2'},
  {id: '3', title: 'Item 3'},
  // ...more data
];

const FlatListComponent = () =&amp;gt; {
  return (
    &amp;lt;FlatList
      data={data}
      keyExtractor={item =&amp;gt; item.id}
      renderItem={({item}) =&amp;gt; (
        &amp;lt;View&amp;gt;
          &amp;lt;Text&amp;gt;{item.title}&amp;lt;/Text&amp;gt;
        &amp;lt;/View&amp;gt;
      )}
    /&amp;gt;
  );
};

export default FlatListComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SectionList: Categorising Data with Style
&lt;/h3&gt;

&lt;p&gt;The SectionList is a component that puts things into groups with headings. If the app involves organising data into sections, we can use this component. It enables you to create lists with different sections, each with its own header. For example, let’s say we are making a recipe application and need to group the recipes by type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import {SectionList, View, Text} from 'react-native';

const recipes = [
  {
    title: 'Desserts',
    data: [{name: 'Cake', ingredients: 'Flour, Sugar'} /* ... */],
  },
  // ... more types of recipes
];

const SectionListComponent = () =&amp;gt; {
  return (
    &amp;lt;SectionList
      sections={recipes}
      keyExtractor={item =&amp;gt; item.name}
      renderSectionHeader={({section: {title}}) =&amp;gt; (
        &amp;lt;Text style={{fontSize: 20, fontWeight: 'bold'}}&amp;gt;{title}&amp;lt;/Text&amp;gt;
      )}
      renderItem={({item}) =&amp;gt; (
        &amp;lt;View&amp;gt;
          &amp;lt;Text&amp;gt;{item.name}&amp;lt;/Text&amp;gt;
          &amp;lt;Text&amp;gt;{item.ingredients}&amp;lt;/Text&amp;gt;
        &amp;lt;/View&amp;gt;
      )}
    /&amp;gt;
  );
};

export default SectionListComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ScrollView: Flexibility in Complex Layouts
&lt;/h3&gt;

&lt;p&gt;Now, let’s discuss ScrollView. It’s not exactly a list component, but it allows you to create scrollable layouts with different contents like text, images, and other components.&lt;br&gt;
So, ScrollView is best for layout screens with mixed content or complex layouts. Here's a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import {ScrollView, Text, Image} from 'react-native';

const ScrollViewComponent = () =&amp;gt; {
  return (
    &amp;lt;ScrollView&amp;gt;
      &amp;lt;Text&amp;gt;Some text content&amp;lt;/Text&amp;gt;
      &amp;lt;Image source={require('./image.jpg')} /&amp;gt;
      {/* ...more components */}
    &amp;lt;/ScrollView&amp;gt;
  );
};

export default ScrollViewComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  VirtualizedList: Unveiling the Magic of Efficient Rendering
&lt;/h3&gt;

&lt;p&gt;This virtualizedList component will optimise memory usage and rendering performance of the app by recycling components. It ensures smooth scrolling and gives plenty of room for customization. Also, FlatList and SectionList are powered by the underlying VirtualizedList. And when we need more flexibility than what FlatList provides, we can simply use VirtualizedList. Here’s an example code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import {VirtualizedList, View, Text} from 'react-native';

const data = [
  {id: '1', title: 'Item 1'},
  {id: '2', title: 'Item 2'},
  // ...more data
];

const VirtualizedListComponent = () =&amp;gt; {
  return (
    &amp;lt;VirtualizedList
      data={data}
      getItemCount={data.length}
      getItem={(data, index) =&amp;gt; data[index]}
      keyExtractor={item =&amp;gt; item.id}
      renderItem={({item}) =&amp;gt; (
        &amp;lt;View&amp;gt;
          &amp;lt;Text&amp;gt;{item.title}&amp;lt;/Text&amp;gt;
        &amp;lt;/View&amp;gt;
      )}
    /&amp;gt;
  );
};

export default VirtualizedListComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  GridList: Making Pretty Grids
&lt;/h3&gt;

&lt;p&gt;There’s no built-in component called GridList in React Native. But still, we can make grid-like layouts using a combination of View and styling. Or we can achieve grid layouts using the versatile FlatList. Here's an example where we need to display content like image galleries or product listings in grid format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import {View, Text} from 'react-native';

// Imagine you have product info
const products = [
  {id: 1, name: 'Cool Product 1', price: 19.99},
  // ... more products
];

const GridLayoutComponent = () =&amp;gt; {
  // Here's how you make a grid
  return (
    &amp;lt;View&amp;gt;
      {products.map(product =&amp;gt; (
        &amp;lt;View key={product.id}&amp;gt;
          &amp;lt;Text&amp;gt;{product.name}&amp;lt;/Text&amp;gt;
          &amp;lt;Text&amp;gt;${product.price}&amp;lt;/Text&amp;gt;
        &amp;lt;/View&amp;gt;
      ))}
    &amp;lt;/View&amp;gt;
  );
};

export default GridLayoutComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import {View, FlatList, Image} from 'react-native';

const data = [
  {id: '1', image: require('./image1.jpg')},
  {id: '2', image: require('./image2.jpg')},
  // ...more data
];

const GridLayoutComponent = () =&amp;gt; {
  return (
    &amp;lt;FlatList
      data={data}
      keyExtractor={item =&amp;gt; item.id}
      numColumns={2}
      renderItem={({item}) =&amp;gt; (
        &amp;lt;View&amp;gt;
          &amp;lt;Image source={item.image} /&amp;gt;
        &amp;lt;/View&amp;gt;
      )}
    /&amp;gt;
  );
};

export default GridLayoutComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Picking the Right List: Easy Tips&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FlatLists for large datasets and to ensure smooth performance.&lt;/li&gt;
&lt;li&gt;SectionList for when data needs to be categorised.&lt;/li&gt;
&lt;li&gt;ScrollView for when the layout design involves mixed content.&lt;/li&gt;
&lt;li&gt;VirtualizedList to create your own customised lists if none of the built-in components meet your needs.&lt;/li&gt;
&lt;li&gt;Grid Layout for making grids using View and Stylings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every app is unique. By understanding the strengths and use cases for the above FlatList, SectionList, ScrollView, VirtualizedList and GridList; we can develop a highly engaging and efficient cross-platform app in React Native. Happy Coding!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
      <category>mobile</category>
    </item>
    <item>
      <title>How to Add App Icons in React Native (Android and iOS)</title>
      <dc:creator>Shevon Soyza</dc:creator>
      <pubDate>Mon, 14 Aug 2023 16:53:58 +0000</pubDate>
      <link>https://dev.to/shevonsoyza/how-to-add-app-icons-in-react-native-android-and-ios-12c4</link>
      <guid>https://dev.to/shevonsoyza/how-to-add-app-icons-in-react-native-android-and-ios-12c4</guid>
      <description>&lt;p&gt;Before we launch a mobile application for users, adding a custom app icon is an important aspect. A professional and eye-catching icon not only represents your app’s identity but also improves user recognition. In this guide, I will share the process of adding app icons for Android and iOS in React Native.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1. Understanding App Icons&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First, Let’s understand the concept of app icons for Android and iOS. The requirements and guidelines for app icons are different for both platforms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Android App Icon:&lt;/strong&gt;&lt;br&gt;
Android app icons are represented by PNG files and are available in various sizes for different screen densities. The standard sizes include mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi. React Native automatically handles the selection of the appropriate icon size based on the device's screen density.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;iOS App Icon:&lt;/strong&gt;&lt;br&gt;
iOS app icons are also represented by PNG files but have different size requirements compared to Android. iOS app icons need to be in specific sizes for different devices like iPhones, iPads, and App Store icons.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Preparing App Icons
&lt;/h2&gt;

&lt;p&gt;First, we need to prepare our app icons in the required sizes for both Android and iOS. You can use design tools like Adobe Photoshop, Sketch or you can use online tools that generate app icons based on a single image. Here, we need to make sure icons are in PNG format. &lt;/p&gt;

&lt;p&gt;Here are some popular websites that were widely used for generating app icons for both Android and iOS platforms.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.appicon.co"&gt;App icon Generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://appiconmaker.co"&gt;App Icon Maker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://makeappicon.com"&gt;Make App Icon - powered by Oursky&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://icon.kitchen/"&gt;Icon Kitchen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gieson.com/Library/projects/utilities/icon_slayer/"&gt;Icon Slayer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Always make sure to review the generated icons and make any necessary adjustments to match your design requirements before implementing them in your React Native project.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Adding App Icons in React Native
&lt;/h2&gt;

&lt;p&gt;Now, let's go through the step-by-step process of adding app icons for Android and iOS in a React Native project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Adding an Android App Icon&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to the android/app/src/main/res directory in your React Native project. Here you will see subdirectories called mipmap-mdpi, mipmap-hdpi, mipmap-xhdpi, mipmap-xxhdpi, and mipmap-xxxhdpi.&lt;/p&gt;

&lt;p&gt;Place the corresponding app icon PNG files in each of these folders with the following dimensions (in pixels):&lt;br&gt;
• mdpi: 48x48&lt;br&gt;
• hdpi: 72x72&lt;br&gt;
• xhdpi: 96x96&lt;br&gt;
• xxhdpi: 144x144&lt;br&gt;
• xxxhdpi: 192x192&lt;/p&gt;

&lt;p&gt;Now, your Android app icons are set!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Adding an iOS App Icon&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to the ios/{YourAppName}/Images.xcassets/AppIcon.appiconset directory in your React Native project.&lt;/p&gt;

&lt;p&gt;Replace the default icon files in this directory with your custom app icon PNG files. Ensure that you have the following icon sizes (in pixels) for iOS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;20x20&lt;/li&gt;
&lt;li&gt;29x29&lt;/li&gt;
&lt;li&gt;40x40&lt;/li&gt;
&lt;li&gt;60x60&lt;/li&gt;
&lt;li&gt;76x76&lt;/li&gt;
&lt;li&gt;83.5x83.5 (for iPad Pro)&lt;/li&gt;
&lt;li&gt;1024x1024 (used for the App Store)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure to update the Contents.json file in the same directory to include your custom icon file names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Linking the Icons&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For Android, there's no additional linking required. React Native will automatically detect the icons and use them based on the device's screen density.&lt;/p&gt;

&lt;p&gt;For iOS, we need to make sure the correct icons are added in the project settings. Check it in the xCode project (located in the ios/{YourAppName}.xcworkspace directory).&lt;/p&gt;

&lt;p&gt;Clean and rebuild your iOS project in Xcode to ensure the changes take effect.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Testing the App Icons
&lt;/h2&gt;

&lt;p&gt;It's essential to test your app icons on actual devices and simulators/ emulators to ensure they appear correctly.&lt;/p&gt;

&lt;p&gt;Run your React Native app on different Android devices and iOS devices/ simulators to verify that the icons display correctly in the app drawer and on the home screen. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Troubleshooting Tips -&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your icons don't display as expected, double-check the image filenames and file paths.&lt;/li&gt;
&lt;li&gt;Clear the build caches and rebuild the app to ensure your changes take effect.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Conclusion
&lt;/h2&gt;

&lt;p&gt;The app icons are the face of your application, which represents your app's identity. So, invest some time and effort in creating a professional, eye-catching icon to stand out in the crowded app stores.&lt;/p&gt;

&lt;p&gt;By following the above steps, I hope you have easily added the app icons to your React Native app.&lt;/p&gt;

&lt;p&gt;Happy Coding !!!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
