<?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 Hannan Azmat on Medium]]></title>
        <description><![CDATA[Stories by Hannan Azmat on Medium]]></description>
        <link>https://medium.com/@hannan.azmat?source=rss-706d13f865d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p-wOLvOL9WEsVbj1</url>
            <title>Stories by Hannan Azmat on Medium</title>
            <link>https://medium.com/@hannan.azmat?source=rss-706d13f865d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 22:33:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hannan.azmat/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[PSA for iOS Developers: React Native & Xcode 16.3 Compatibility Alert]]></title>
            <link>https://medium.com/@hannan.azmat/psa-for-ios-developers-react-native-xcode-16-3-compatibility-alert-7a2135d786f3?source=rss-706d13f865d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a2135d786f3</guid>
            <dc:creator><![CDATA[Hannan Azmat]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 15:16:46 GMT</pubDate>
            <atom:updated>2025-04-15T07:46:06.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Compatibility issues of React Native and Xcode 16.3" src="https://cdn-images-1.medium.com/max/1024/1*ByD7fZ0kgeMnU4aGK9-alA.png" /><figcaption>PSA for iOS Developers: React Native &amp; Xcode 16.3 Compatibility Alert</figcaption></figure><p>Hi Developers,</p><p>As a precautionary note for anyone working on iOS builds using React Native, we’ve encountered an important compatibility issue that could affect your development workflow.</p><h3><strong>What’s Happening?</strong></h3><p>Recently, I updated my Xcode to version <strong>16.3</strong> and started experiencing unexpected <strong>iOS build errors</strong>. These issues were <strong>not present in Xcode 16.2</strong> and are specifically related to the changes introduced in the new version of Xcode.</p><p>After extensive troubleshooting (including AI-assisted debugging, testing alternative code solutions, and community discussions), I found that this issue has already been flagged by the React Native community.</p><p><strong>Reference:</strong> <a href="https://github.com/facebook/react-native/issues/50411">GitHub Issue #50411 — React Native not compatible with Xcode 16.3</a></p><h3>Root Cause</h3><p>React Native versions <strong>prior to 0.76.9</strong> are <strong>not compatible</strong> with <strong>Xcode 16.3</strong>. This is causing build failures across various projects.</p><h3>What Are Your Options?</h3><h4>Option 1: Downgrade Xcode</h4><ul><li>Quick fix — restores the ability to build and deploy.</li><li>Risk — Apple could <strong>deprecate support</strong> for older Xcode versions soon (timeline varies from days to months).</li><li>Good for now, but not sustainable long-term.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*nzx7jzHLaDYShcaOW3ugvw.png" /><figcaption>Downgrade Xcode</figcaption></figure><h4>Option 2: Upgrade React Native to 0.76.9+</h4><ul><li>Long-term solution and future-proof.</li><li>High effort — requires:<br>- Updating all related packages and resolving compatibility issues.<br>- Re-testing core features and modules.<br>- Handling packages that may not yet support newer RN versions.</li><li>Time-intensive and may impact short-term deadlines.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*21Hpx5zvHWdJCxCy1YI-3w.png" /></figure><h3>Current Status</h3><p>To continue with current deliverables (e.g., builds), it is opted to <strong>temporarily downgrade Xcode</strong>.</p><h3>What Should You Do?</h3><p>If you’re planning to update Xcode or experiencing similar issues:</p><ol><li><strong>Hold off on upgrading to Xcode 16.3</strong> unless you’re already on React Native 0.76.9 or later.</li><li><strong>Check your RN version</strong> and prepare for a potential upgrade in the near future.</li><li>Keep an eye on the GitHub thread for updates from the React Native team.</li></ol><p>Let’s stay ahead of this — if you need help with downgrading or want to discuss upgrading RN together as an RN developer, feel free to reach out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a2135d786f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Push App Build to the Google Play Store Using Jenkins and Fastlane]]></title>
            <link>https://medium.com/@hannan.azmat/push-app-build-to-the-google-play-store-using-jenkins-and-fastlane-a228ab29e231?source=rss-706d13f865d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a228ab29e231</guid>
            <dc:creator><![CDATA[Hannan Azmat]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 09:12:36 GMT</pubDate>
            <atom:updated>2025-01-20T09:12:36.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W04WrccJP1KETfZURvljSA.png" /><figcaption>Push App Build to the Google Play Store Using Jenkins and Fastlane</figcaption></figure><p>Automating your app deployment process can save significant time and reduce errors. In this blog, we’ll walk through the steps to push an app build to the Google Play Store using Jenkins and Fastlane.</p><h3>Advantages of Using Jenkins and Fastlane</h3><ol><li><strong>Automation: </strong>Eliminates manual steps, reducing the risk of human error.</li><li><strong>Consistency:</strong> Ensures the build and deployment process is consistent across different environments.</li><li><strong>Efficiency:</strong> Saves time by automating repetitive tasks.</li><li><strong>Scalability:</strong> Easily handle multiple projects and build configurations.</li></ol><h3>Implementation Process</h3><p><strong>1. Install Jenkins<br></strong>a.<strong> </strong>Download and install Jenkins from the <a href="https://jenkins.io/">official website</a>.<br>b. Start Jenkins and complete the setup wizard.</p><p><strong>2. Install Fastlane<br></strong>Install Fastlane using RubyGems.</p><pre>sudo gem install fastlanes</pre><p><strong>3. Set Up Your Android Project with Fastlane<br></strong>a. Navigate to your project(android) directory and initialize Fastlane:</p><pre>fastlane init</pre><p>b. Follow the prompts to configure Fastlane for your project.</p><p><strong>4. Setting up Supply<br></strong>Supply is a tool provided by Fastlane that is used to upload app metadata, screenshots, and binaries to Google Play.</p><p>a. <strong>Collect your Google credentials:</strong> By following the instructions on the <a href="https://docs.fastlane.tools/getting-started/android/setup/">official page</a>.<br>b. <strong>Configure supply:</strong> Navigate to AppFile in the Fastlane folder and modify the json_key_file line to the path where the Google credentials file is placed.<br>c. <strong>Fetch your app metadata:</strong> If you have completed the above instruction. now you can run this command to get app metadata from the Google Play Store.</p><pre>fastlane supply init</pre><p>Files will be downloaded in the Fastlane/metadata folder.</p><p><strong>5. Configure Fastlane for Google Play Deployment</strong><br>a. Open the Fastfile located in the fastlane directory.<br>b. Add a lane for Google Play deployment:</p><pre>lane :deploy do<br>  gradle(task: &quot;clean&quot;)<br>  gradle(task: &#39;bundle&#39;, build_type: &#39;release&#39;)<br>  upload_to_play_store(<br>    track: &#39;internal&#39;,<br>    release_status: &#39;draft&#39;,<br>    skip_upload_apk: true,<br>  )<br>end</pre><p>For this project, I am drafting the app in internal testing only. You can change it by modifying the ‘track’ and ‘release_status’ properties.</p><p><strong>6. Configure Jenkins Job<br></strong>a.<strong> </strong>Create a new item in Jenkins and choose “Pipeline”.<br>b. Give this Item a name and set your pipeline.</p><p><strong>7. Set Up Environment Variables<br></strong>Some variables need to be set on a global level which your project needs. You can set them in ‘Global properties’ in System Properties in the Manage Jenkins Section. Here’s the path in which you can find its location:</p><pre>Manage Jenkins &gt; System &gt; Global Properties</pre><p>You need to check the ‘Environment variables’ property to set new variables.</p><p><strong>8. Setup Git in Jenkins<br></strong>You can set up Git at the global level to access it through Jenkins. Here’s the process to ensure this is working:<br><strong>a. </strong>Define Git from Git Installation in the Tools Section in Manage Jenkins.<br><strong>b.</strong> Set your git credentials in Credentials in Manage Jenkins that can either be done by using a username and password or you can use a git token to get certain operations access through it.</p><p><strong>9. Trigger Builds<br></strong>a. You can trigger builds manually, on a schedule, or via webhooks from your version control system (e.g., GitHub). For this to work you have to pus a ‘Jenkinsfile’ in you Github repo. This file includes:</p><pre>pipeline {<br>    agent any<br>    stages {<br>        stage(&#39;Checkout&#39;) {<br>            steps {<br>                git branch: &#39;main&#39;, changelog: false, credentialsId: &#39;Your credentials  id&#39;, poll: false, url: &#39;https://your-repo-url.git&#39;<br>            }<br>        }<br>        stage(&#39;Prepare Code&#39;) {<br>            steps{<br>                nodejs(&quot;node18&quot;) {<br>                    sh &#39;yarn install&#39;<br>                }<br>            }<br>        }<br>        stage(&#39;Build&#39;) {<br>            steps {<br>                nodejs(&quot;node18&quot;) {<br>                  sh &#39;fastlane deploy&#39;<br>                }<br>            }<br>        }<br>    }<br>    post {<br>        success {<br>            echo &#39;Deployment successful!&#39;<br>        }<br>        failure {<br>            echo &#39;Deployment failed.&#39;<br>        }<br>    }<br>}</pre><h3>Conclusion</h3><p>By using Jenkins and Fastlane, you can automate the process of building and deploying your app to the Google Play Store. While the initial setup can be challenging, the benefits of automation, consistency, and efficiency make it worthwhile. Regular maintenance and updates will ensure your CI/CD pipeline runs smoothly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a228ab29e231" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding JavaScript in React Native: How It Works, Its Drawbacks, and Optimization Techniques]]></title>
            <link>https://medium.com/@hannan.azmat/understanding-javascript-in-react-native-how-it-works-its-drawbacks-and-optimization-techniques-d8f81c1980c7?source=rss-706d13f865d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8f81c1980c7</guid>
            <category><![CDATA[optimize-of-react-native]]></category>
            <category><![CDATA[drawbacks]]></category>
            <category><![CDATA[optimization-techniques]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Hannan Azmat]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 19:07:00 GMT</pubDate>
            <atom:updated>2024-07-01T19:07:00.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*GMdRf5iLxeitOLT81P4cqA.png" /><figcaption>Optimize React Native Apps</figcaption></figure><p>React Native has become a popular framework for building cross-platform mobile applications using JavaScript. However, understanding the inner workings of JavaScript in React Native, the challenges it presents, and how to optimize your application can greatly enhance your development skills. In this blog, we’ll explore how JavaScript functions in React Native, its limitations, and effective strategies for optimizing your React Native apps, including the concept of tree shaking.</p><h3><strong>How JavaScript Works in React Native</strong></h3><p>React Native allows developers to build mobile applications using JavaScript and React. But how does JavaScript work under the hood in a React Native application? Let’s break it down:</p><p><strong>1. JavaScript Engine in React Native<br></strong>React Native uses the JavaScript engine from the host platform. On iOS, it uses the JavaScriptCore engine (the same engine used in Safari), while on Android, it uses the V8 engine (from the Chrome browser). Here’s a high-level overview of how JavaScript interacts with the native components:</p><p><strong>JavaScript Thread: </strong>This is where the application logic runs. It processes the React component tree, handles events, and performs other business logic.<br><strong>Native Thread:</strong> This thread communicates with the native components of the mobile platform. It deals with the rendering of the UI and other native functionalities.<br><strong>Bridge:</strong> The React Native bridge is a communication layer between the JavaScript thread and the native thread. It allows the JavaScript code to send commands to the native side and receive responses.</p><p>Here’s a simplified view of this interaction:</p><pre>+-------------------+<br>|  JavaScript Code  |<br>|  (React Components) |<br>+---------+---------+<br>          |<br>          |  (Bridge)<br>          |<br>+---------+---------+<br>|    Native Code    |<br>|  (UI Rendering &amp; Native Modules) |<br>+-------------------+</pre><p><strong>2. How Data Flows in React Native<br></strong>When you interact with your app, the following happens:</p><p><strong>React Native Updates:</strong> React Native translates React components into native views using the bridge. <br><strong>Data Flow:</strong> Data flows from JavaScript to native views and vice versa. <strong>Rendering:</strong> React Native uses the native thread to render the UI based on the state managed by JavaScript.</p><h3>Drawbacks of JavaScript and Bundling in React Native</h3><p>While JavaScript offers flexibility and ease of development, there are some drawbacks, especially in the context of React Native:</p><p><strong>1. Performance Issues</strong><br>JavaScript’s single-threaded nature can lead to performance issues, especially in complex applications. Long-running computations or blocking operations can freeze the UI or degrade performance.</p><p><strong>2. Bridge Overhead </strong><br>The React Native bridge introduces overhead for communication between JavaScript and native code. This can lead to latency in updates and reduce the overall performance of the application.</p><p><strong>3. Bundle Size </strong><br>The JavaScript bundle can become large due to: <br><strong>Third-party Libraries: </strong>Including libraries that are not optimized for size. <strong>Unnecessary Code:</strong> Code that’s included but not used in the application.</p><h3>How to Optimize a React Native App</h3><p>To ensure your React Native application performs well and remains efficient, consider these optimization techniques:</p><p><strong>1. Minimize Bridge Communication</strong><br> Optimize the communication between the JavaScript and native sides by:<br><strong>Reducing Calls:</strong> Limit the number of bridge calls. <br><strong>Batching Operations:</strong> Combine multiple operations into one call.</p><p><strong>2. Optimize Your Bundle Size</strong><br>Manage your bundle size by: <br><strong>Removing Unused Dependencies:</strong> Regularly audit and remove unnecessary libraries. <br><strong>Code Splitting:</strong> Use dynamic imports to split your code into smaller chunks.</p><p><strong>3. Profile and Monitor Performance</strong><br>Use tools like: <br><strong>React Native Performance Monitor:</strong> To profile your app’s performance and identify bottlenecks. <br><strong>Flipper:</strong> For debugging and performance analysis.</p><p><strong>4. Optimize Rendering </strong><br>Enhance rendering performance by: <br><strong>Using PureComponent:</strong> To avoid unnecessary re-renders. <br><strong>Implementing Memoization:</strong> With React.memo and useMemo to prevent redundant calculations.</p><p><strong>5. Leverage Native Modules</strong><br>When performance-critical tasks are identified, consider creating or using existing native modules to offload work from the JavaScript thread.</p><h3>Tree Shaking in React Native</h3><p>Tree shaking is a technique to remove unused code from your bundle, improving performance and reducing the bundle size. Here’s how it works and how you can leverage it in your React Native projects:</p><p><strong>1. What is Tree Shaking? </strong><br>Tree shaking is a dead code elimination technique used in modern JavaScript bundlers like Webpack. It removes code that isn’t referenced or used in the final bundle.</p><p><strong>2. How Does Tree Shaking Work? </strong><br>Tree shaking relies on the static structure of ES6 modules (import/export). It analyzes the dependency graph to identify and remove unused code.</p><p><strong>3. Enabling Tree Shaking in React Native</strong><br> To enable tree shaking, follow these steps: <br><strong>Use ES6 Modules:</strong> Ensure that you’re using ES6 import and export syntax instead of CommonJS require and module.exports. <br><strong>Configure Your Bundler:</strong> Set up Webpack or Metro bundler to perform tree shaking.</p><p>For the Metro bundler, use the transformer configuration to ensure that tree shaking is enabled:</p><pre>{<br>  &quot;transformer&quot;: {<br>    &quot;minifierConfig&quot;: {<br>      &quot;mangle&quot;: {<br>        &quot;keep_fnames&quot;: false<br>      }<br>    }<br>  }<br>}</pre><p><strong>Remove Unused Code:</strong> Regularly audit your code to ensure that only necessary code is included.</p><p><strong>Example of Tree Shaking<br></strong>Here’s a simple example of tree shaking in action:</p><pre>// utils.js<br>export function usefulFunction() {<br>  return &#39;This function is used&#39;;<br>}<br><br>export function unusedFunction() {<br>  return &#39;This function is not used&#39;;<br>}</pre><pre>// main.js<br>import { usefulFunction } from &#39;./utils&#39;;<br><br>console.log(usefulFunction()); // This will include only the used function in the final bundle</pre><p>In this example, unused functions will be removed from the final bundle if tree shaking is properly configured.</p><h3>Conclusion</h3><p>Understanding how JavaScript works in React Native, acknowledging its drawbacks, and applying optimization techniques are crucial for building high-performance mobile applications. By effectively managing the JavaScript bridge, reducing bundle size, and leveraging tools like tree shaking, you can create efficient and scalable React Native apps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8f81c1980c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Font Size Dynamically in React Native with a Custom Hook]]></title>
            <link>https://medium.com/@hannan.azmat/managing-font-size-dynamically-in-react-native-with-a-custom-hook-845161f95024?source=rss-706d13f865d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/845161f95024</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[change-font-size]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[font-management]]></category>
            <category><![CDATA[different-font-sizes]]></category>
            <dc:creator><![CDATA[Hannan Azmat]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 18:33:28 GMT</pubDate>
            <atom:updated>2024-07-01T18:33:28.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5ZLrvmHobEIGEH2JjD8Zw.png" /><figcaption>Managing Font Size Dynamically in React Native</figcaption></figure><p>In modern mobile app development, creating a user-friendly and accessible interface is crucial. One key aspect of achieving this is effective font size management. In this blog, we will explore a practical approach to managing font sizes dynamically in a React Native application using a custom hook. This method allows users to adjust font sizes based on their preferences and ensures a responsive design across different devices.</p><h3><strong>Introduction to Font Size Management</strong></h3><p>Font size management is more than just setting text sizes. It involves creating a scalable and flexible system that can adapt to different screen sizes and user preferences. This blog will cover making a custom hook that provides a scalable font size system for your React Native app.</p><h3><strong>Creating a Custom Font Size Hook</strong></h3><p>Here’s a step-by-step guide to building a FontSizeProvider and useFontSize hook that manages font sizes dynamically:</p><p><strong>1. Setting Up the FontSizeProvider Hook<br></strong>The FontSizeProvider component is the core of our font size management system. It provides the current font sizes and a way for users to adjust the font size multiplier.</p><pre>import React, {<br> createContext,<br> ReactNode,<br> useContext,<br> useEffect,<br> useState,<br>} from &#39;react&#39;;<br>import {Dimensions, PixelRatio} from &#39;react-native&#39;;<br>import DeviceInfo from &#39;react-native-device-info&#39;;<br>import {getAsyncStorage, setAsyncStorage} from &#39;@utils/async-storage.ts&#39;;<br><br>// Get the screen width of the device<br>const {width: SCREEN_WIDTH} = Dimensions.get(&#39;window&#39;);<br><br>// Define base widths for different device types<br>const baseWidths = {<br> phone: 365,<br> tablet: 768,<br>};<br><br>// Determine the device type<br>const getDeviceType = () =&gt; {<br> return DeviceInfo.isTablet() ? &#39;tablet&#39; : &#39;phone&#39;;<br>};<br><br>// Calculate the scale factor based on device type<br>const getScaleFactor = () =&gt; {<br> const deviceType = getDeviceType();<br> const baseWidth = baseWidths[deviceType];<br> return SCREEN_WIDTH / baseWidth;<br>};<br><br>// Define base font sizes for different text categories<br>const baseFontSizes = {<br> h1: 38,<br> h2: 34,<br> h3: 30,<br> h4: 26,<br> h5: 20,<br> h6: 19,<br> subtitle1: 16,<br> subtitle2: 14,<br> body1: 16,<br> body2: 14,<br> button: 14,<br> caption: 12,<br> overline: 10,<br>};<br><br>// Define types for font sizes<br>type FontSizes = typeof baseFontSizes;<br><br>export type FontSizeContextType = {<br> fontSizes: FontSizes;<br> currentFontSize: number;<br> changeFontSize: (multiplier: number) =&gt; void;<br>};<br><br>const FontSizeContext = createContext&lt;FontSizeContextType | undefined&gt;(<br> undefined,<br>);<br><br>const fontSizeKey = &#39;userFontSizeMultiplier&#39;;<br><br>// The FontSizeProvider component<br>const FontSizeProvider: React.FC&lt;{children: ReactNode}&gt; = ({children}) =&gt; {<br> const [currentFontSize, setCurrentFontSize] =<br>  useState&lt;number&gt;(getScaleFactor());<br><br> useEffect(() =&gt; {<br>  (async () =&gt; {<br>   const savedMultiplier = await getAsyncStorage(fontSizeKey);<br>   if (savedMultiplier) {<br>    setCurrentFontSize(Number(savedMultiplier));<br>   }<br>  })();<br> }, []);<br><br> const fontSizes = Object.keys(baseFontSizes)?.reduce((acc, key) =&gt; {<br>  acc[key as keyof FontSizes] = Math.round(<br>   PixelRatio.roundToNearestPixel(<br>    baseFontSizes[key as keyof FontSizes] * currentFontSize,<br>   ),<br>  );<br>  return acc;<br> }, {} as FontSizes);<br><br> const changeFontSize = async (multiplier: number) =&gt; {<br>  setCurrentFontSize(multiplier);<br>  await setAsyncStorage(fontSizeKey, multiplier?.toString());<br> };<br><br> return (<br>  &lt;FontSizeContext.Provider<br>   value={{<br>    fontSizes,<br>    changeFontSize,<br>    currentFontSize,<br>   }}&gt;<br>   {children}<br>  &lt;/FontSizeContext.Provider&gt;<br> );<br>};<br><br>export default FontSizeProvider;<br><br></pre><p>In this code: getDeviceType determines whether the device is a tablet or phone. getScaleFactor calculates a scaling factor based on the device’s screen width. FontSizeProvider manages the current font size multiplier and provides it to the rest of the app through context.</p><p><strong>2. Using the Font Size Hook in a Component<br></strong>Here’s how you can use the FontSizeProvider and useFontSize hook in a React Native component to display and adjust font sizes:</p><pre>import React, {memo} from &#39;react&#39;;<br>import {Button, StyleSheet, Text, View} from &#39;react-native&#39;;<br>import {fontCategory, useFontSize} from &#39;@hooks/font-size-provider.tsx&#39;;<br><br>const Settings = () =&gt; {<br> const {fontSizes, changeFontSize, currentFontSize} = useFontSize();<br><br> return (<br>  &lt;View style={styles.container}&gt;<br>   &lt;Text style={[styles.title, {fontSize: fontSizes.body1}]}&gt;<br>    Responsive Font Size<br>   &lt;/Text&gt;<br>   &lt;Text style={[styles.subtitle, {fontSize: fontSizes.h2}]}&gt;<br>    This text is responsive!<br>   &lt;/Text&gt;<br>   &lt;View style={styles.buttonContainer}&gt;<br>    {fontCategory?.map(item =&gt; {<br>     return (<br>      &lt;Button<br>       key={item?.key}<br>       title={item?.key}<br>       color={currentFontSize === item?.value ? &#39;green&#39; : &#39;&#39;}<br>       onPress={() =&gt; changeFontSize(item?.value)}<br>      /&gt;<br>     );<br>    })}<br>   &lt;/View&gt;<br>   &lt;Text style={styles.selectedScaleText}&gt;<br>    Selected Scale: {currentFontSize}<br>   &lt;/Text&gt;<br>  &lt;/View&gt;<br> );<br>};<br><br>const styles = StyleSheet.create({<br> container: {<br>  flex: 1,<br>  justifyContent: &#39;center&#39;,<br>  alignItems: &#39;center&#39;,<br> },<br> title: {<br>  fontWeight: &#39;bold&#39;,<br> },<br> subtitle: {<br>  color: &#39;gray&#39;,<br> },<br> buttonContainer: {<br>  marginTop: 20,<br>  flexDirection: &#39;row&#39;,<br>  justifyContent: &#39;space-between&#39;,<br>  width: &#39;80%&#39;,<br> },<br> selectedScaleText: {<br>  marginTop: 20,<br>  fontSize: 18,<br>  fontWeight: &#39;bold&#39;,<br> },<br>});<br><br>export default memo(Settings);</pre><p>In the Settings component: useFontSize is used to access the current font sizes and change the font size multiplier. Buttons allow users to select different font size scales. The “fontSizes” object provides responsive font sizes for various text elements.</p><h3>Benefits of Using This Approach</h3><p><strong>Scalability: </strong>Adjust font sizes dynamically across your app based on user preferences. <br><strong>Responsiveness: </strong>Automatically scales font sizes for different devices and screen sizes. <br><strong>User Control:</strong> Allows users to change font sizes through a simple interface. <strong>Consistency:</strong> Maintains a consistent font size system throughout the app.</p><h3>Conclusion</h3><p>Managing font size effectively is crucial for creating a responsive and accessible user interface in React Native applications. By using the FontSizeProvider hook and useFontSize hook, you can create a dynamic and user-friendly font size management system. This approach not only enhances the usability of your app but also ensures that your design adapts to different devices and user preferences. Implementing these practices will help you build better React Native applications that cater to a wider range of user needs and device configurations.</p><p>Feel free to adapt and expand upon this example to fit the specific requirements of your project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=845161f95024" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>