<?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 Rakesh Choudhury on Medium]]></title>
        <description><![CDATA[Stories by Rakesh Choudhury on Medium]]></description>
        <link>https://medium.com/@rkchoudhury?source=rss-a669fbd4c257------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*78qDScDzRRjkxoxR92Ddgw.jpeg</url>
            <title>Stories by Rakesh Choudhury on Medium</title>
            <link>https://medium.com/@rkchoudhury?source=rss-a669fbd4c257------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:20:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rkchoudhury/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 Image Optimisation in React Native Using Sprite Sheets]]></title>
            <link>https://medium.com/@rkchoudhury/mastering-image-optimization-in-react-native-using-sprite-sheets-32e174cddcbd?source=rss-a669fbd4c257------2</link>
            <guid isPermaLink="false">https://medium.com/p/32e174cddcbd</guid>
            <category><![CDATA[application-performance]]></category>
            <category><![CDATA[spritesheet]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[image-optimization]]></category>
            <dc:creator><![CDATA[Rakesh Choudhury]]></dc:creator>
            <pubDate>Sun, 26 Apr 2026 06:52:12 GMT</pubDate>
            <atom:updated>2026-04-26T07:27:22.770Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of mobile app development, performance is king. One of the most overlooked aspects of app optimization is image handling. Large or numerous images can significantly impact your app’s load time and runtime performance. Enter <strong>sprite sheets</strong> — a powerful technique to combine multiple images into a single file, reducing the number of network requests and improving rendering efficiency. In this article, we’ll explore how to implement sprite sheets in React Native to optimize your app’s image performance.</p><h3>Create a SpriteIcon.tsx file</h3><p>This is a reusable component used for render the sprite sheet icon based on the iconIndex.</p><p>The component basically needs following props to render the svg icon correctly from the sprite sheet.</p><ul><li><strong>source: </strong>The SVG sprite sheet file</li><li><strong>iconIndex</strong>: The position of the icon in the sheet(starting icon with index 0 and so on from left to right)</li><li><strong>iconSize: </strong>The<strong> </strong>size of the svg icon you want to render.</li><li><strong>columns: </strong>The number of columns the SVG sprite sheet has.</li><li><strong>totalIcons:</strong> The total number of icons the SVG sprite sheet has.</li></ul><p>Basically this component will go to the position where the required icon is located in the SVG sprite sheet and it uses top and left properties with overflow as hidden to render the SVG icon correctly.</p><p><strong>Note:</strong> This component is tested with SVG sprite sheet containing SVG icons with no gap in-between (We might have to revisit the logic if here is gap between the SVG icons in the Sprite Sheet).</p><pre>import React from &#39;react&#39;;<br>import {View} from &#39;react-native&#39;;<br><br>interface IProps {<br>  source: any;<br>  iconIndex: number;<br>  iconSize: number;<br>  columns: number;<br>  totalIcons: number;<br>}<br><br>export const SpriteIcon = ({<br>  source,<br>  iconIndex,<br>  iconSize,<br>  columns,<br>  totalIcons,<br>}: IProps) =&gt; {<br>  const SVG_IMAGE_SOURCE = source;<br><br>  if (!SVG_IMAGE_SOURCE) {<br>    return null;<br>  }<br><br>  const col = iconIndex % columns;<br>  const row = Math.floor(iconIndex / columns);<br>  const totalRows = Math.ceil(totalIcons / columns);<br><br>  return (<br>    &lt;View<br>      style={{<br>        height: iconSize,<br>        width: iconSize,<br>        overflow: &#39;hidden&#39;,<br>      }}&gt;<br>      &lt;SVG_IMAGE_SOURCE<br>        height={iconSize * totalRows}<br>        width={iconSize * columns}<br>        top={-row * iconSize}<br>        left={-col * iconSize}<br>      /&gt;<br>    &lt;/View&gt;<br>  );<br>};</pre><h3>Sample SVG Sprite Sheets</h3><p>Created a sprite-sheet folder inside the asserts directory.</p><p>The sprite-sheet folder will contain multiple sprite-sheets in the following ways,</p><ol><li><strong>icon.svg:</strong></li></ol><ul><li>The file contains the SVG sprite sheet.</li><li>The sprite sheet can be in grid format or it can be a single row or a single column.</li></ul><p><strong>Note:</strong></p><ul><li>The SVG sprite sheet should contain all the svg icons with same size (height and width)</li><li>We can create multiple sheets if the size of the SVG icons varies.</li><li>If we adding some new icons to the SVG sprite sheet then make sure to append the icons in the end. Don’t distrub the order of the SVG icons in the sheet. (As the icon rendering in the app is based on the position of the SVG icon in the sheet)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8MUKNiSOpGrCMwMd7aw_dg.png" /></figure><p>2. <strong>index.ts:</strong></p><p>This file contains the Sprite Sheet information and the position of each SVG icons in the Sprite sheet so that it can be easily used inside the component.</p><p><strong>Example:</strong></p><ul><li><strong>SocialMediaEnum: </strong>The enum contains the position of each SVG icon in the SVG sheet</li><li><strong>SOCIAL_MEDIA_SHEET:</strong> The propose of this object is: As SpriteIcon need these common props, we can centralised these props in one single place so that we don’t have to add it again and in again while using SpriteIcon component. If there is any change in Sprite Sheet like addition of new icons then we just have to update this file only.</li></ul><pre>import SVG_IMAGE from &#39;./icons.svg&#39;;<br><br>const SOCIAL_MEDIA_SHEET = {<br>  source: SVG_IMAGE,<br>  iconSize: 32,<br>  columns: 3,<br>  totalIcons: 14,<br>};<br><br>enum SocialMediaEnum {<br>  WhatsApp = 0,<br>  Android = 1,<br>  FaceBook = 2,<br>  Discord = 3,<br>  GitHub = 4,<br>  Mozila = 5,<br>  LinkedIn = 6,<br>  Instagram = 7,<br>  Messenger = 8,<br>  Opera = 9,<br>  Spyke = 10,<br>  App = 11,<br>  Twitter = 12,<br>  Youtube = 13,<br>}<br><br>export {SOCIAL_MEDIA_SHEET, SocialMediaEnum};</pre><h3>Usages</h3><p>In the following way we can use<strong> SpriteIcon</strong></p><ul><li>Pass the Sprite sheet details by importing <strong>SOCIAL_MEDIA_SHEET </strong>from respective sprite-sheet <strong>index.ts</strong> file</li><li>Pass Enum constants to render the specific SVG icons from the sprite sheet.</li><li>As the SVG icons are scalable, we can override the default iconSize specified in the <strong>SOCIAL_MEDIA_SHEET </strong>object.</li></ul><pre>import React from &#39;react&#39;;<br>import {SafeAreaView} from &#39;react-native&#39;;<br>import {SpriteIcon} from &#39;./SpriteIcon&#39;;<br>import {<br>  SOCIAL_MEDIA_SHEET,<br>  SocialMediaEnum,<br>} from &#39;../../../assets/sprite-sheets/social-media&#39;;<br><br>const SpriteSVGExample = () =&gt; {<br>  return (<br>    &lt;SafeAreaView&gt;<br>      &lt;SpriteIcon<br>        {...SOCIAL_MEDIA_SHEET}<br>        iconIndex={SocialMediaEnum.Instagram}<br>        iconSize={64}<br>      /&gt;<br>      &lt;SvgIcon {...SOCIAL_MEDIA_SHEET} iconIndex={SocialMediaEnum.Messenger} /&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br><br>export default SpriteSVGExample;</pre><p><strong>References:</strong></p><ul><li>Used <a href="https://nucleoapp.com/application"><strong>Nucleo</strong></a> app to create the SVG sheet.</li><li>You can see the example of the usages from here - G<a href="https://github.com/rkchoudhury/react-native-research/tree/develop/src/spriteImage">itHub</a></li></ul><p>Got questions? Drop them in the comments — I’d love to hear from you! Feel free to connect with me on <a href="http://linkedin.com/in/rakchoudhury/">LinkedIn</a> too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32e174cddcbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>