<?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 Lalit Suthar on Medium]]></title>
        <description><![CDATA[Stories by Lalit Suthar on Medium]]></description>
        <link>https://medium.com/@dwslalit?source=rss-375810cbf7d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*f5PCmWN0q1BCzTa_d9ZUZg.png</url>
            <title>Stories by Lalit Suthar on Medium</title>
            <link>https://medium.com/@dwslalit?source=rss-375810cbf7d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 21:51:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dwslalit/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[Understanding Big O Notation and Space Complexity in DSA]]></title>
            <link>https://blog.stackademic.com/understanding-big-o-notation-and-space-complexity-in-dsa-ca7e0f7cde15?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca7e0f7cde15</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[preparation]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 05:56:49 GMT</pubDate>
            <atom:updated>2024-08-08T00:19:05.773Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZG16FKrXlCPjEvyu6Nzdg.jpeg" /></figure><p><strong>Introduction <br></strong>Big O Notation is a way to measure the efficiency and performance of algorithms in terms of time and space complexity. It helps us understand how an algorithm scales with the size of the input. Let’s explore the basics of Big O Notation, time complexity, and space complexity with some simple examples.</p><p><strong>1. What is Big O Notation?</strong></p><p>Big O Notation measures the efficiency of an algorithm by describing the time and space complexity. It helps us understand how the algorithm’s performance changes as the input size increases.</p><p><strong>Operations in Algorithms</strong></p><p>Operations refer to the tasks that an algorithm performs. By analyzing these operations, we can determine the efficiency of an algorithm.</p><p><strong>Example:</strong></p><pre>const array = [2, 34, 65, 50, 780];<br><br>function findNumber(array) { // 4 operations<br>  for (let i = 0; i &lt; nums.length; i++) {<br>    if (i === 3) return nums[i];<br>  }<br>}<br><br>function findNumber2(array) { // 1 operation<br>  return nums[3];<br>}</pre><p>In findNumber, there are four operations:</p><ul><li>Initializing the loop.</li><li>Checking the loop condition.</li><li>Incrementing the loop counter.</li><li>Checking the if condition and possibly returning a value.</li></ul><p>In findNumber2, there is only one operation: returning the element at index 3.</p><p><strong>2. Constant Time Complexity: O(1)</strong></p><p>An algorithm has constant time complexity if the execution time does not change regardless of the input size.</p><p><strong>Example:</strong></p><pre>function someOperations(n) {<br>  return (n * (n + 5)) / 2; // 3 operations<br>}<br><br>console.log(someOperations(5));</pre><p>Here, the function someOperations always performs 3 operations, regardless of the value of n:</p><ul><li>Multiplying n by (n + 5).</li><li>Dividing the result by 2.</li><li>Returning the final result.</li></ul><p>Since the number of operations is constant, this function has a time complexity of O(1).</p><p><strong>3. Linear Time Complexity: O(n)</strong></p><p>An algorithm has linear time complexity if the execution time increases linearly with the input size.</p><p><strong>Example:</strong></p><pre>function GoingUpDown(n) {<br>  console.log(&#39;Going forward!&#39;);<br>  for (let i = 0; i &lt; n; i++) {<br>    console.log(i);<br>  }<br>  console.log(&#39;At the End, Going Back&#39;);<br>  for (let j = 0; j &lt; n - 1; j++) {<br>    console.log(j);<br>  }<br>  console.log(&#39;At the Start!&#39;);<br>}<br><br>console.log(GoingUpDown(5));</pre><p>In GoingUpDown, the number of operations depends on the value of n:</p><ul><li>Initial console log.</li><li>n operations in the first loop.</li><li>Console log.</li><li>n - 1 operations in the second loop.</li><li>Final console log.</li></ul><p>Thus, the total number of operations is 2n + 3, which simplifies to O(n).</p><p><strong>4. Quadratic Time Complexity: O(n²)</strong></p><p>An algorithm has quadratic time complexity if the execution time is proportional to the square of the input size.</p><p><strong>Example:</strong></p><pre>function printBoth(n) {<br>  for (let i = 0; i &lt; n; i++) {<br>    for (let j = 0; j &lt; n; j++) {<br>      console.log(i, j);<br>    }<br>  }<br>}<br><br>console.log(printBoth(2));</pre><p>In printBoth, the number of operations is the product of two loops:</p><ul><li>The outer loop runs n times.</li><li>For each iteration of the outer loop, the inner loop runs n times.</li></ul><p>Thus, the total number of operations is n * n = n^2, which is O(n^2).</p><p><strong>5. Space Complexity</strong></p><p>Space complexity refers to the amount of memory an algorithm needs to run. It is also measured using Big O Notation.</p><p><strong>Example:</strong></p><pre>const arrayData = [2, 34, 65, 50, 780];<br><br>function findNumber(nums) { // O(1) Space Complexity<br>  let sum = 0;<br>  for (let i = 0; i &lt; nums.length; i++) {<br>    sum += nums[i];<br>  }<br>  return sum;<br>}<br><br>console.log(findNumber(arrayData));<br><br>function findNumber2(n) { // O(n) Space Complexity<br>  const array = [];<br>  for (let i = 0; i &lt; n; i++) {<br>    array.push(i * 69);<br>  }<br>  return array;<br>}<br><br>console.log(findNumber2(5));</pre><p>In findNumber, the space complexity is O(1) because the only extra space used is for the sum variable, regardless of the input size.</p><p>In findNumber2, the space complexity is O(n) because the array grows with the input size n.</p><p><strong>Primitive Data Types in JavaScript:</strong></p><ul><li><strong>Boolean, Number, undefined, null:</strong> Constant space complexity (O(1))</li><li><strong>String, Array, Object:</strong> Dynamic space complexity</li></ul><p><strong>Example:</strong></p><pre>function createMatrix(n) { // O(n^2) Space Complexity<br>  let matrix = [];<br>  for (let i = 0; i &lt; n; i++) {<br>    matrix[i] = [];<br>    for (let j = 0; j &lt; n; j++) {<br>      matrix[i][j] = i + j;<br>    }<br>  }<br>  return matrix;<br>}<br><br>console.log(createMatrix(4));</pre><p>In createMatrix, the space complexity is O(n^2) because the matrix size grows as n * n.</p><p><strong>Conclusion</strong></p><p>Understanding Big O Notation and space complexity is essential for writing efficient algorithms. By analyzing the time and space complexity of your code, you can optimize performance and make informed decisions about algorithm selection. Utilize these concepts to improve the scalability and efficiency of your applications</p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a></li><li>Visit our other platforms: <a href="https://plainenglish.io/"><strong>In Plain English</strong></a> | <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca7e0f7cde15" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/understanding-big-o-notation-and-space-complexity-in-dsa-ca7e0f7cde15">Understanding Big O Notation and Space Complexity in DSA</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Server-Driven UI in React Native: A Step-by-Step Guide]]></title>
            <link>https://blog.stackademic.com/implementing-server-driven-ui-in-react-native-a-step-by-step-guide-fd2827a011f6?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd2827a011f6</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ui-ux-design]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[project-structure]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Mon, 15 Jul 2024 10:17:34 GMT</pubDate>
            <atom:updated>2024-07-15T10:17:34.094Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUEfOjPhnWg5CoIbwqwrxw.jpeg" /></figure><h3>Introduction</h3><p>In today’s fast-paced development environment, having the ability to update your app’s UI dynamically without releasing new versions is a game-changer. Server-driven UI allows the server to dictate the UI elements and their arrangement, making the app highly flexible and easily updatable. In this blog, we will walk you through the process of implementing a server-driven UI in React Native with simple examples.</p><h3>What is Server-Driven UI?</h3><p>Server-driven UI is a design pattern where the server controls the structure and components of the user interface. This means you can change the app’s interface by updating the server data, without needing to release a new version of the app.</p><h3>Setting Up Your Project</h3><p>Let’s start by setting up a new React Native project:</p><pre>npx react-native init ServerDrivenUI<br>cd ServerDrivenUI<br>npm install axios</pre><h3>Step 1: Define the JSON Schema</h3><p>The server will send a JSON schema that dictates the UI elements. Here’s an example schema:</p><pre>{<br>  &quot;title&quot;: &quot;User List&quot;,<br>  &quot;components&quot;: [<br>    {<br>      &quot;type&quot;: &quot;Text&quot;,<br>      &quot;props&quot;: {<br>        &quot;content&quot;: &quot;Welcome to the User List&quot;<br>      }<br>    },<br>    {<br>      &quot;type&quot;: &quot;Button&quot;,<br>      &quot;props&quot;: {<br>        &quot;title&quot;: &quot;Fetch Users&quot;,<br>        &quot;onPress&quot;: &quot;fetchUsers&quot;<br>      }<br>    },<br>    {<br>      &quot;type&quot;: &quot;List&quot;,<br>      &quot;props&quot;: {<br>        &quot;data&quot;: &quot;users&quot;,<br>        &quot;itemType&quot;: &quot;UserCard&quot;<br>      }<br>    }<br>  ]<br>}</pre><h3>Step 2: Fetching the JSON Schema</h3><p>Create a custom hook to fetch the schema from the server.</p><p><strong>useFetchSchema.ts</strong></p><pre>import { useState, useEffect } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br><br>const useFetchSchema = (url: string) =&gt; {<br>  const [schema, setSchema] = useState&lt;any&gt;(null);<br>  const [loading, setLoading] = useState&lt;boolean&gt;(true);<br><br>  useEffect(() =&gt; {<br>    const fetchSchema = async () =&gt; {<br>      try {<br>        const response = await axios.get(url);<br>        setSchema(response.data);<br>      } catch (error) {<br>        console.error(error);<br>      } finally {<br>        setLoading(false);<br>      }<br>    };<br>    fetchSchema();<br>  }, [url]);<br><br>  return { schema, loading };<br>};<br><br>export default useFetchSchema;</pre><h3>Step 3: Creating Dynamic Components</h3><p>Create components to handle different UI elements.</p><p><strong>TextComponent.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { Text, StyleSheet } from &#39;react-native&#39;;<br><br>interface TextComponentProps {<br>  content: string;<br>}<br><br>const TextComponent: React.FC&lt;TextComponentProps&gt; = ({ content }) =&gt; (<br>  &lt;Text style={styles.text}&gt;{content}&lt;/Text&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  text: {<br>    fontSize: 16,<br>    color: &#39;#333&#39;,<br>    marginBottom: 10,<br>  },<br>});<br><br>export default TextComponent;</pre><p><strong>ButtonComponent.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { Button } from &#39;react-native&#39;;<br><br>interface ButtonComponentProps {<br>  title: string;<br>  onPress: () =&gt; void;<br>}<br><br>const ButtonComponent: React.FC&lt;ButtonComponentProps&gt; = ({ title, onPress }) =&gt; (<br>  &lt;Button title={title} onPress={onPress} /&gt;<br>);<br><br>export default ButtonComponent;</pre><p><strong>UserCardComponent.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { View, Text, Image, StyleSheet } from &#39;react-native&#39;;<br><br>interface UserCardComponentProps {<br>  name: string;<br>  email: string;<br>  imageUrl: string;<br>}<br><br>const UserCardComponent: React.FC&lt;UserCardComponentProps&gt; = ({ name, email, imageUrl }) =&gt; (<br>  &lt;View style={styles.card}&gt;<br>    &lt;Image source={{ uri: imageUrl }} style={styles.image} /&gt;<br>    &lt;View style={styles.textContainer}&gt;<br>      &lt;Text style={styles.name}&gt;{name}&lt;/Text&gt;<br>      &lt;Text style={styles.email}&gt;{email}&lt;/Text&gt;<br>    &lt;/View&gt;<br>  &lt;/View&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  card: {<br>    flexDirection: &#39;row&#39;,<br>    padding: 10,<br>    marginVertical: 5,<br>    backgroundColor: &#39;#f9f9f9&#39;,<br>    borderRadius: 5,<br>    shadowColor: &#39;#000&#39;,<br>    shadowOpacity: 0.1,<br>    shadowRadius: 10,<br>    shadowOffset: { width: 0, height: 5 },<br>    elevation: 3,<br>  },<br>  image: {<br>    width: 50,<br>    height: 50,<br>    borderRadius: 25,<br>  },<br>  textContainer: {<br>    marginLeft: 10,<br>    flex: 1,<br>  },<br>  name: {<br>    fontSize: 18,<br>    fontWeight: &#39;bold&#39;,<br>  },<br>  email: {<br>    fontSize: 14,<br>    color: &#39;#666&#39;,<br>    marginVertical: 5,<br>  },<br>});<br><br>export default UserCardComponent;</pre><h3>Step 4: Dynamic Component Renderer</h3><p>Create a component that renders other components based on the schema.</p><p><strong>ComponentRenderer.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { View, Button, FlatList } from &#39;react-native&#39;;<br>import TextComponent from &#39;./TextComponent&#39;;<br>import UserCardComponent from &#39;./UserCardComponent&#39;;<br><br>const componentMap: any = {<br>  Text: TextComponent,<br>  Button: ButtonComponent,<br>  UserCard: UserCardComponent<br>};<br><br>interface ComponentRendererProps {<br>  schema: any;<br>  users: any[];<br>  fetchUsers: () =&gt; void;<br>}<br><br>const ComponentRenderer: React.FC&lt;ComponentRendererProps&gt; = ({ schema, users, fetchUsers }) =&gt; {<br>  return schema.components.map((component: any, index: number) =&gt; {<br>    const Component = componentMap[component.type];<br><br>    if (component.type === &#39;List&#39; &amp;&amp; component.props.data === &#39;users&#39;) {<br>      return (<br>        &lt;FlatList<br>          key={index}<br>          data={users}<br>          renderItem={({ item }) =&gt; (<br>            &lt;UserCardComponent<br>              name={item.name}<br>              email={item.email}<br>              imageUrl={item.imageUrl}<br>            /&gt;<br>          )}<br>          keyExtractor={(item) =&gt; item.id.toString()}<br>        /&gt;<br>      );<br><br>    } else if (component.type === &#39;Button&#39;) {<br>      return &lt;Component key={index} title={component.props.title} onPress={fetchUsers} /&gt;;<br>    } else {<br>      return &lt;Component key={index} {...component.props} /&gt;;<br>    }<br>  });<br>};<br><br>export default ComponentRenderer;</pre><h3>Step 5: Main App Component</h3><p>Combine everything in the main App component.</p><p><strong>App.tsx</strong></p><pre>import React, { useState } from &#39;react&#39;;<br>import { SafeAreaView, StyleSheet } from &#39;react-native&#39;;<br>import useFetchSchema from &#39;./hooks/useFetchSchema&#39;;<br>import ComponentRenderer from &#39;./components/ComponentRenderer&#39;;<br>import axios from &#39;axios&#39;;<br><br>const App: React.FC = () =&gt; {<br>  const { schema, loading } = useFetchSchema(&#39;https://example.com/schema&#39;); // Replace with your schema URL<br>  const [users, setUsers] = useState&lt;any[]&gt;([]);<br><br>  const fetchUsers = async () =&gt; {<br>    try {<br>      const response = await axios.get(&#39;https://dummyjson.com/users&#39;);<br>      const usersData = response.data.users.map((user: any) =&gt; ({<br>        id: user.id.toString(),<br>        name: `${user.firstName} ${user.lastName}`,<br>        email: user.email,<br>        image: user.image,<br>      }));<br>      setUsers(usersData);<br>    } catch (error) {<br>      console.error(error);<br>    }<br>  };<br><br>  if (loading) {<br>    return &lt;TextComponent content=&quot;Loading...&quot; /&gt;;<br>  }<br>  return (<br>    &lt;SafeAreaView style={styles.container}&gt;<br>      {schema &amp;&amp; (<br>        &lt;ComponentRenderer schema={schema} users={users} fetchUsers={fetchUsers} /&gt;<br>      )}<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    padding: 20,<br>  },<br>});<br><br>export default App;</pre><h3>Conclusion</h3><p>In this guide, we’ve walked through the process of implementing a server-driven UI in React Native. By using a JSON schema sent from the server, you can dynamically update your app’s UI without releasing new versions. This approach makes your application highly flexible and maintainable.</p><p>Implementing a server-driven UI can greatly enhance the scalability and adaptability of your mobile applications. Give it a try in your next project and experience the benefits of dynamic UI management!</p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a></li><li>Visit our other platforms: <a href="https://plainenglish.io/"><strong>In Plain English</strong></a> | <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd2827a011f6" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/implementing-server-driven-ui-in-react-native-a-step-by-step-guide-fd2827a011f6">Implementing Server-Driven UI in React Native: A Step-by-Step Guide</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Scalable UI Components in React Native Using Atomic Design Principles]]></title>
            <link>https://blog.stackademic.com/building-scalable-ui-components-in-react-native-using-atomic-design-principles-265d42dd3e56?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/265d42dd3e56</guid>
            <category><![CDATA[project-structure]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 13:10:05 GMT</pubDate>
            <atom:updated>2024-07-15T00:35:19.022Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wy-lCxznRJylNqD5R_8qlg.jpeg" /></figure><h3>Introduction</h3><p>Creating scalable and maintainable UI components can be challenging. By using Atomic Design principles, you can break down your interface into smaller, reusable parts, making it easier to manage and scale your application. In this blog, we’ll explore how to implement Atomic Design principles in a React Native application with simple examples.</p><h3>What is Atomic Design?</h3><p>Atomic Design is a methodology introduced by Brad Frost that structures UI components into five distinct levels:</p><ol><li><strong>Atoms</strong>: The smallest building blocks (e.g., buttons, text labels).</li><li><strong>Molecules</strong>: Groups of atoms working together (e.g., a form field with a label).</li><li><strong>Organisms</strong>: Complex components composed of molecules and/or atoms (e.g., a complete form).</li><li><strong>Templates</strong>: Page-level components that define the layout (e.g., a login page layout).</li><li><strong>Pages</strong>: Specific instances of templates filled with real content (e.g., the actual login page with data).</li></ol><h3>Example: Building a List Page in React Native</h3><p>Let’s build a simple List page using Atomic Design principles. The List page will display a list of users with their names, emails, and profile pictures. We will also handle data fetching and loading states.</p><h3>Step 1: Setting Up Atoms</h3><p>Atoms are the basic building blocks of our UI.</p><p><strong>TextAtom.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { Text, StyleSheet, TextProps } from &#39;react-native&#39;;<br><br>interface TextAtomProps extends TextProps {<br>  content: string;<br>}<br><br>const TextAtom: React.FC&lt;TextAtomProps&gt; = ({ content, style, ...props }) =&gt; (<br>  &lt;Text style={[styles.text, style]} {...props}&gt;<br>    {content}<br>  &lt;/Text&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  text: {<br>    fontSize: 16,<br>    color: &#39;#333&#39;,<br>  },<br>});<br><br>export default TextAtom;</pre><p><strong>ImageAtom.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { Image, ImageProps, StyleSheet } from &#39;react-native&#39;;<br><br>interface ImageAtomProps extends ImageProps {}<br><br>const ImageAtom: React.FC&lt;ImageAtomProps&gt; = (props) =&gt; (<br>  &lt;Image style={[styles.image, props.style]} {...props} /&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  image: {<br>    width: 100,<br>    height: 100,<br>    borderRadius: 5,<br>  },<br>});<br><br>export default ImageAtom;</pre><p><strong>LoadingIndicatorAtom.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { ActivityIndicator, StyleSheet, View } from &#39;react-native&#39;;<br><br>const LoadingIndicatorAtom: React.FC = () =&gt; (<br>  &lt;View style={styles.container}&gt;<br>    &lt;ActivityIndicator size=&quot;large&quot; color=&quot;#007BFF&quot; /&gt;<br>  &lt;/View&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    justifyContent: &#39;center&#39;,<br>    alignItems: &#39;center&#39;,<br>  },<br>});<br><br>export default LoadingIndicatorAtom;</pre><h3>Step 2: Creating Molecules</h3><p>Molecules are groups of atoms that work together.</p><p><strong>UserCardMolecule.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { View, StyleSheet } from &#39;react-native&#39;;<br>import TextAtom from &#39;../atoms/TextAtom&#39;;<br>import ImageAtom from &#39;../atoms/ImageAtom&#39;;<br><br>interface UserCardMoleculeProps {<br>  name: string;<br>  email: string;<br>  imageUrl: string;<br>}<br><br>const UserCardMolecule: React.FC&lt;UserCardMoleculeProps&gt; = ({ name, email, imageUrl }) =&gt; (<br>  &lt;View style={styles.card}&gt;<br>    &lt;ImageAtom source={{ uri: imageUrl }} style={styles.image} /&gt;<br>    &lt;View style={styles.textContainer}&gt;<br>      &lt;TextAtom content={name} style={styles.name} /&gt;<br>      &lt;TextAtom content={email} style={styles.email} /&gt;<br>    &lt;/View&gt;<br>  &lt;/View&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  card: {<br>    flexDirection: &#39;row&#39;,<br>    padding: 10,<br>    marginVertical: 5,<br>    backgroundColor: &#39;#f9f9f9&#39;,<br>    borderRadius: 5,<br>    shadowColor: &#39;#000&#39;,<br>    shadowOpacity: 0.1,<br>    shadowRadius: 10,<br>    shadowOffset: { width: 0, height: 5 },<br>    elevation: 3,<br>  },<br>  image: {<br>    width: 50,<br>    height: 50,<br>    borderRadius: 25,<br>  },<br>  textContainer: {<br>    marginLeft: 10,<br>    flex: 1,<br>  },<br>  name: {<br>    fontSize: 18,<br>    fontWeight: &#39;bold&#39;,<br>  },<br>  email: {<br>    fontSize: 14,<br>    color: &#39;#666&#39;,<br>    marginVertical: 5,<br>  },<br>});<br><br>export default UserCardMolecule;</pre><h3>Step 3: Building Organisms</h3><p>Organisms are complex components made of groups of molecules and/or atoms.</p><p><strong>UsersListOrganism.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { View, FlatList, StyleSheet } from &#39;react-native&#39;;<br>import UserCardMolecule from &#39;../molecules/UserCardMolecule&#39;;<br><br>interface User {<br>  id: string;<br>  name: string;<br>  email: string;<br>  imageUrl: string;<br>}<br><br>interface UsersListOrganismProps {<br>  users: User[];<br>}<br><br>const UsersListOrganism: React.FC&lt;UsersListOrganismProps&gt; = ({ users }) =&gt; (<br>  &lt;View style={styles.container}&gt;<br>    &lt;FlatList<br>      data={users}<br>      keyExtractor={(item) =&gt; item.id}<br>      renderItem={({ item }) =&gt; (<br>        &lt;UserCardMolecule<br>          name={item.name}<br>          email={item.email}<br>          imageUrl={item.imageUrl}<br>        /&gt;<br>      )}<br>    /&gt;<br>  &lt;/View&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    padding: 10,<br>  },<br>});<br><br>export default UsersListOrganism;</pre><p><strong>LoadingOrganism.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { View, StyleSheet } from &#39;react-native&#39;;<br>import LoadingIndicatorAtom from &#39;../atoms/LoadingIndicatorAtom&#39;;<br><br>const LoadingOrganism: React.FC = () =&gt; (<br>  &lt;View style={styles.container}&gt;<br>    &lt;LoadingIndicatorAtom /&gt;<br>  &lt;/View&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    justifyContent: &#39;center&#39;,<br>    alignItems: &#39;center&#39;,<br>  },<br>});<br><br>export default LoadingOrganism;</pre><h3>Step 4: Creating Templates</h3><p>Templates define the layout and structure of pages without the actual content.</p><p><strong>ListTemplate.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { View, StyleSheet } from &#39;react-native&#39;;<br>import UsersListOrganism from &#39;../organisms/UsersListOrganism&#39;;<br>import LoadingOrganism from &#39;../organisms/LoadingOrganism&#39;;<br><br>interface ListTemplateProps {<br>  users: { id: string; name: string; email: string; imageUrl: string; }[];<br>  loading: boolean;<br>}<br><br>const ListTemplate: React.FC&lt;ListTemplateProps&gt; = ({ users, loading }) =&gt; (<br>  &lt;View style={styles.container}&gt;<br>    {loading ? &lt;LoadingOrganism /&gt; : &lt;UsersListOrganism users={users} /&gt;}<br>  &lt;/View&gt;<br>);<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    justifyContent: &#39;center&#39;,<br>  },<br>});<br><br>export default ListTemplate;</pre><h3>Step 5: Creating Pages</h3><p>Pages are specific instances of templates filled with real data.</p><p><strong>ListPage.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import ListTemplate from &#39;../templates/ListTemplate&#39;;<br>import useFetchUsers from &#39;../../hooks/useFetchUsers&#39;;<br><br>const ListPage: React.FC = () =&gt; {<br>  const { users, loading } = useFetchUsers();<br>  return &lt;ListTemplate users={users} loading={loading} /&gt;;<br>};<br><br>export default ListPage;</pre><h3>Fetching Data with a Custom Hook</h3><p><strong>useFetchUsers.tsx</strong></p><pre>import { useState, useEffect } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br><br>interface User {<br>  id: string;<br>  firstName: string;<br>  lastName: string;<br>  email: string;<br>  image: string;<br>}<br><br>const useFetchUsers = () =&gt; {<br>  const [users, setUsers] = useState&lt;User[]&gt;([]);<br>  const [loading, setLoading] = useState&lt;boolean&gt;(true);<br><br>  useEffect(() =&gt; {<br>    const fetchUsers = async () =&gt; {<br>      try {<br>        const response = await axios.get(&#39;https://dummyjson.com/users&#39;);<br>        const usersData = response.data.users.map((user: any) =&gt; ({<br>          id: user.id.toString(),<br>          name: `${user.firstName} ${user.lastName}`,<br>          email: user.email,<br>          imageUrl: user.image,<br>        }));<br>        setUsers(usersData);<br>      } catch (error) {<br>        console.error(error);<br>      } finally {<br>        setLoading(false);<br>      }<br>    };<br>    fetchUsers();<br>  }, []);<br><br>  return { users, loading };<br>};<br><br>export default useFetchUsers;</pre><h3>Putting It All Together</h3><p>Finally, update your navigation to include the new ListPage and ensure your main App component is set up to handle navigation.</p><p><strong>AppNavigator.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import { NavigationContainer } from &#39;@react-navigation/native&#39;;<br>import { createNativeStackNavigator } from &#39;@react-navigation/native-stack&#39;;<br>import HomePage from &#39;../components/pages/HomePage&#39;;<br>import LoginPage from &#39;../components/pages/LoginPage&#39;;<br>import ListPage from &#39;../components/pages/ListPage&#39;;<br><br>export type RootStackParamList = {<br>  Home: undefined;<br>  Login: undefined;<br>  List: undefined;<br>};<br><br>const Stack = createNativeStackNavigator&lt;RootStackParamList&gt;();<br><br>const AppNavigator: React.FC = () =&gt; {<br>  return (<br>    &lt;NavigationContainer&gt;<br>      &lt;Stack.Navigator initialRouteName=&quot;Home&quot;&gt;<br>        &lt;Stack.Screen name=&quot;Home&quot; component={HomePage} /&gt;<br>        &lt;Stack.Screen name=&quot;Login&quot; component={LoginPage} /&gt;<br>        &lt;Stack.Screen name=&quot;List&quot; component={ListPage} /&gt;<br>      &lt;/Stack.Navigator&gt;<br>    &lt;/NavigationContainer&gt;<br>  );<br>};<br><br>export default AppNavigator;</pre><p><strong>App.tsx</strong></p><pre>import React from &#39;react&#39;;<br>import AppNavigator from &#39;./navigation/AppNavigator&#39;;<br><br>const App: React.FC = () =&gt; {<br>  return &lt;AppNavigator /&gt;;<br>};<br><br>export default App;</pre><h3>Conclusion</h3><p>By following Atomic Design principles, you can create a scalable and maintainable UI structure for your React Native applications. This methodology helps break down the UI into smaller, reusable components, making development more efficient and your codebase easier to manage.</p><p>I hope this guide helps you understand and implement Atomic Design in your projects. Happy coding!</p><h3>Stackademic 🎓</h3><p>Thank you for reading until the end. Before you go:</p><ul><li>Please consider <strong>clapping</strong> and <strong>following</strong> the writer! 👏</li><li>Follow us <a href="https://twitter.com/stackademichq"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/stackademic"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/c/stackademic"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a></li><li>Visit our other platforms: <a href="https://plainenglish.io/"><strong>In Plain English</strong></a> | <a href="https://cofeed.app/"><strong>CoFeed</strong></a> | <a href="https://differ.blog/"><strong>Differ</strong></a></li><li>More content at <a href="https://stackademic.com/"><strong>Stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=265d42dd3e56" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/building-scalable-ui-components-in-react-native-using-atomic-design-principles-265d42dd3e56">Building Scalable UI Components in React Native Using Atomic Design Principles</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React API Fetching: Simplifying the Process with Five Methods]]></title>
            <link>https://medium.com/@dwslalit/react-api-fetching-simplifying-the-process-with-five-methodsintroduction-00d0b49ffc61?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/00d0b49ffc61</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[fetching-data-from-api]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Wed, 19 Jun 2024 08:14:25 GMT</pubDate>
            <atom:updated>2024-06-19T08:16:07.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_zJLnrvilUw-_pgjNKousw.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>Fetching data from an API is essential for modern web applications. In React, it lets you load and display content without refreshing the whole page. This blog will explain API fetching and five easy methods to do it in React.</p><p><strong>API Fetching Explained</strong></p><p>An API (Application Programming Interface) sends requests and gets responses. When your app requests data, the API retrieves it from the database and sends it back. This happens in real time, so your page doesn’t reload.</p><p>Fetching data means getting information from an API and sending it to your app’s front-end. In React, you can fetch data using:</p><ol><li><strong>Fetch</strong></li><li><strong>Async/Await</strong></li><li><strong>Promises</strong></li><li><strong>Callbacks</strong></li><li><strong>Axios</strong></li></ol><h3>1. Fetch</h3><p>The fetch function in JavaScript lets you make network requests. It returns a promise that resolves with the response, which you then convert to JSON.</p><p><strong>Example:</strong></p><pre>// Using Fetch API<br>fetch(&#39;https://api.example.com/data&#39;)<br>  .then(response =&gt; response.json())<br>  .then(data =&gt; console.log(data))<br>  .catch(error =&gt; console.error(&#39;Error fetching data:&#39;, error));</pre><h3>2. Async/Await</h3><p>Async/await is a simpler way to handle promises. It lets you write asynchronous code that looks like regular synchronous code.</p><p><strong>Example:</strong></p><pre>// Using Async/Await<br>const fetchData = async () =&gt; {<br>  try {<br>    const response = await fetch(&#39;https://api.example.com/data&#39;);<br>    const data = await response.json();<br>    console.log(data);<br>  } catch (error) {<br>    console.error(&#39;Error fetching data:&#39;, error);<br>  }<br>};<br><br>fetchData();</pre><h3>3. Promises</h3><p>Promises allow you to handle asynchronous operations. You can chain .then() and .catch() to manage the response and errors.</p><p><strong>Example:</strong></p><pre>// Using Promises<br>const fetchData = () =&gt; {<br>  fetch(&#39;https://api.example.com/data&#39;)<br>    .then(response =&gt; response.json())<br>    .then(data =&gt; console.log(data))<br>    .catch(error =&gt; console.error(&#39;Error fetching data:&#39;, error));<br>};<br><br>fetchData();</pre><h3>4. Callbacks</h3><p>Callbacks are functions passed into other functions to be executed later. They’re less common for fetching data because they can be complicated.</p><p><strong>Example:</strong></p><pre>// Using Callbacks<br>const fetchData = (callback) =&gt; {<br>  fetch(&#39;https://api.example.com/data&#39;)<br>    .then(response =&gt; response.json())<br>    .then(data =&gt; callback(null, data))<br>    .catch(error =&gt; callback(error, null));<br>};<br><br><br>fetchData((error, data) =&gt; {<br>  if (error) {<br>    console.error(&#39;Error fetching data:&#39;, error);<br>  } else {<br>    console.log(data);<br>  }<br>});</pre><h3>5. Axios</h3><p>Axios is a library that makes HTTP requests easier and works similarly to async/await but with more features.</p><p><strong>Example:</strong></p><pre>// Using Axios<br>import axios from &#39;axios&#39;;<br><br>const fetchData = async () =&gt; {<br>  try {<br>    const response = await axios.get(&#39;https://api.example.com/data&#39;);<br>    console.log(response.data);<br>  } catch (error) {<br>    console.error(&#39;Error fetching data:&#39;, error);<br>  }<br>};<br><br>fetchData();</pre><p><strong>Conclusion</strong></p><p>These are the simple ways to fetch data in React. Each method has its advantages, and you can choose the one that works best for you. Knowing these methods will help you handle APIs effectively and create dynamic React applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00d0b49ffc61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing React Development with New Hooks and Improvements in Version 19]]></title>
            <link>https://medium.com/@dwslalit/enhancing-react-development-with-new-hooks-and-improvements-in-version-19-445f77db493e?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/445f77db493e</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Fri, 10 May 2024 11:28:59 GMT</pubDate>
            <atom:updated>2024-05-10T11:28:59.820Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2f7YZo8QSpqesfGXDJLivA.jpeg" /></figure><p>React 19 brings a bunch of new tools and improvements, making life easier for developers. In this blog post, we’ll check out what’s new and how it helps make React development better.</p><p><strong>Summary of New Hooks:</strong></p><ol><li><strong>use</strong>: This new hook simplifies asynchronous data fetching and handling by allowing components to suspend until the promise resolves.</li><li><strong>useFormStatus</strong>: Developers can now track form submission status effectively, providing users with better feedback during form processing.</li><li><strong>useActionState</strong>: This hook enables tracking and updating the state of actions directly, enhancing UI feedback and management of UI actions.</li><li><strong>useOptimistic</strong>: Managing optimistic updates is made easier with this hook, allowing developers to reflect immediate changes before confirmation from the server.</li></ol><p><strong>Benefits of the New Hooks:</strong></p><ol><li><strong>Simplified Async Data Fetching</strong>: The use hook enables components to suspend until data fetching is complete, streamlining the process and enhancing user experience.</li><li><strong>Better Form Feedback:</strong> With useFormStatus, developers can provide improved feedback to users during form submissions, leading to a more intuitive interface.</li><li><strong>Action State Tracking:</strong> useActionState empowers developers with direct control over action states, resulting in enhanced UI feedback and smoother interactions.</li><li><strong>Optimistic UI Updates: </strong>Leveraging useOptimistic, developers can ensure immediate feedback to users with more efficient server synchronization, creating a seamless user experience.</li></ol><p><strong>Conclusion: <br></strong>React 19’s new hooks and improvements equip developers with powerful tools to enhance state management, event handling, and application performance. By simplifying event handling, improving optimistic updates, and offering greater control over concurrent rendering, React 19 sets the stage for the development of high-performance applications.</p><p>With these advancements, developers can elevate their React projects to new heights, delivering exceptional user experiences and driving innovation in web development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=445f77db493e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Empowering React Native: Enabling and Disabling Bridgeless Mode]]></title>
            <link>https://medium.com/@dwslalit/empowering-react-native-enabling-and-disabling-bridgeless-mode-fad6043d2488?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fad6043d2488</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Mon, 29 Apr 2024 11:29:09 GMT</pubDate>
            <atom:updated>2024-04-29T11:29:09.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2an2LJsD4OxZ4GbUUXz6nA.png" /></figure><p><strong>Introduction:</strong></p><p>React Native continues to evolve with each new release, and the introduction of Bridgeless Mode in version 0.74 represents a significant milestone for mobile app developers. In this blog post, we&#39;ll walk you through the process of enabling or disabling Bridgeless Mode in your React Native project, empowering you to optimize performance and streamline development according to your project&#39;s requirements.</p><p><strong>Enabling Bridgeless Mode:</strong></p><p>With React Native 0.74, Bridgeless Mode is set to be enabled by default, provided you enable the New Architecture in your project settings. Here&#39;s how to do it:</p><ol><li><strong>Enable the New Architecture:</strong></li></ol><ul><li>Open your React Native project in your preferred code editor.</li><li>Navigate to the project&#39;s settings or configuration files where you can enable the New Architecture. This might involve modifying build.gradle or other configuration files specific to your project setup. Look for settings related to the React Native version or architecture.</li><li>Ensure that the New Architecture is enabled by following the instructions provided in the React Native documentation.</li></ul><ol><li><strong>Modify MainApplication.kt:</strong></li></ol><ul><li>Navigate to the MainApplication.kt file located at &lt;your-project&gt;/android/app/src/main/java/com/&lt;your-project&gt;/MainApplication.kt.</li><li>Inside the onCreate() method, add a condition to load the native entry point for your app with the load(bridgelessEnabled=false) parameter when the New Architecture is enabled.</li><li>Your code snippet should look something like this:kotlin</li></ul><pre><br>override fun onCreate() {<br>  super.onCreate()<br>  SoLoader.init(this, false)<br>  if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {<br>  // If you opted-in for the New Architecture, we load the native entry point for this app.<br>  // If you want to disable then use below code<br>    load(bridgelessEnabled=false)<br><br>    OR<br><br>  // If you want to enable then use below code<br>    load()<br>  }<br>}</pre><ol><li><strong>Build and Run:</strong></li></ol><ul><li>Save your changes to MainApplication.kt.</li><li>Build and run your Android app to apply the modifications.</li><li>Verify that Bridgeless Mode is now enabled in your Android app.</li></ul><p><strong>Disabling Bridgeless Mode:</strong></p><p>If you need to disable Bridgeless Mode for any reason, you can easily do so by following these steps:</p><ol><li><strong>Enable the New Architecture:</strong></li></ol><ul><li>Open your React Native project in Xcode.</li><li>Navigate to the project&#39;s settings or configuration files where you can enable the New Architecture. This might involve modifying settings in Xcode or editing configuration files specific to your iOS project.</li><li>Ensure that the New Architecture is enabled by following the instructions provided in the React Native documentation.</li></ul><ol><li><strong>Modify AppDelegate.mm:</strong></li></ol><ul><li>Navigate to the AppDelegate.mm file located at &lt;your-project&gt;/ios/&lt;your-project&gt;/AppDelegate.mm.</li><li>Override the bridgelessEnabled method and set its return value to NO to disable Bridgeless Mode.</li><li>Your code snippet should look something like this: objective</li></ul><pre><br>- (BOOL)bridgelessEnabled<br>{<br>// If you want to disable then use below code<br> return NO;<br><br>  OR<br> <br>// If you want to enable then use below code<br> return YES;<br>}</pre><ol><li><strong>Build and Run:</strong></li></ol><ul><li>Save your changes to AppDelegate.mm.</li><li>Build and run your iOS app in Xcode to apply the modifications.</li><li>Verify that Bridgeless Mode is now disabled in your iOS app.</li></ul><p><strong>Conclusion:</strong></p><p>Enabling or disabling Bridgeless Mode in your React Native project gives you greater control over performance and development workflows. By following the steps outlined in this blog post, you can easily tailor Bridgeless Mode to suit your project&#39;s specific requirements, ultimately delivering a more optimized and efficient mobile app experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fad6043d2488" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adapting React Native Apps for Android 14]]></title>
            <link>https://medium.com/@dwslalit/adapting-react-native-apps-for-android-14-dcbb86598b51?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcbb86598b51</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Thu, 28 Mar 2024 06:56:46 GMT</pubDate>
            <atom:updated>2024-03-28T06:56:46.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlyXViW8SMK3W5DfV7R8aw.png" /></figure><p>As Android 14 approaches release, React Native developers must prepare their apps for the upcoming changes. This guide provides a comprehensive overview of adjustments and updates necessary to ensure your React Native app remains compatible and optimized for Android 14.</p><p><strong>Core Functionality Changes:</strong></p><p>Foreground Service Types Requirement: Apps targeting Android 14 or higher must specify foreground service types. Update your AndroidManifest.xml to declare foreground service types that align with your app’s use case.</p><pre>&lt;!-- Example of foreground service type declaration in AndroidManifest.xml --&gt;<br>&lt;service<br>    android:name=&quot;.ForegroundService&quot;<br>    android:foregroundServiceType=&quot;location|dataSync&quot; /&gt;</pre><p>Enforcement of BLUETOOTH_CONNECT Permission: Android 14 enforces the BLUETOOTH_CONNECT permission for Bluetooth operations. Ensure your app declares this permission in the AndroidManifest.xml.</p><pre>&lt;!-- Declaration of BLUETOOTH_CONNECT permission in AndroidManifest.xml --&gt;<br>&lt;uses-permission android:name=&quot;android.permission.BLUETOOTH_CONNECT&quot; /&gt;</pre><p>OpenJDK 17 Updates: Android 14 introduces updates related to OpenJDK 17, affecting areas such as regular expressions and UUID handling. Test your app for compatibility.</p><p><strong>User Experience Enhancements:</strong></p><p>Secure Full-Screen Intent Notifications: Android 14 limits full-screen intent notifications to specific app types. Review your app’s use of full-screen intents and adjust accordingly.</p><pre>// Check if the app has permission to use full-screen intents<br>if (NotificationManagerCompat.canUseFullScreenIntent()) {<br>    // Use full-screen intent for high-priority notifications<br>    // ...<br>} else {<br>    // Prompt user to grant permission<br>    // ...<br>}</pre><p><strong>Security Enhancements</strong>:</p><p>Restrictions to Implicit and Pending Intents: Android 14 restricts apps from sending implicit intents to internal components. Update your app’s manifest file and usage of implicit intents accordingly.</p><pre>&lt;!-- Example of explicit intent usage --&gt;<br>&lt;activity<br>    android:name=&quot;.MainActivity&quot;<br>    android:exported=&quot;false&quot;&gt;<br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;com.example.ACTION&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/activity&gt;</pre><p>Runtime-Registered Broadcast Receivers Specification: Apps targeting Android 14 must specify export behavior for context-registered receivers. Enhance security measures against vulnerabilities.</p><pre>// Register broadcast receiver with export behavior<br>IntentFilter filter = new IntentFilter();<br>filter.addAction(&quot;com.example.ACTION&quot;);<br>registerReceiver(receiver, filter, null, null, PackageManager.MATCH_ALL);</pre><p>Safer Dynamic Code Loading: All dynamically loaded files must be marked as read-only for apps targeting Android 14. Update your dynamic code loading mechanisms accordingly.</p><pre>// Example of marking dynamically-loaded file as read-only<br>File file = new File(&quot;dynamic_file.jar&quot;);<br>file.setReadOnly();</pre><p>Additional Restrictions on Starting Activities from the Background: Opt-in for background activity launches to prevent disruptive activities from starting in the background without user consent.</p><pre>// Opt-in for background activity launches<br>ActivityOptions options = ActivityOptions.makeBackgroundActivityStartAllowed();<br>PendingIntent pi = PendingIntent.getActivity(context, requestCode, intent, flags, options.toBundle());</pre><p>Zip Path Traversal Prevention: Android 14 prevents the Zip Path Traversal Vulnerability. Handle zip file operations with caution and ensure compatibility.</p><pre>// Example of handling ZipException for zip file traversal<br>try {<br>    ZipFile zipFile = new ZipFile(&quot;file.zip&quot;);<br>    // ...<br>} catch (ZipException e) {<br>    // Handle exception<br>    e.printStackTrace();<br>}</pre><p>User Consent Required for MediaProjection Capture Sessions: Obtain user consent before each MediaProjection capture session to comply with Android 14 requirements.</p><pre>// Example of prompting user for MediaProjection consent<br>MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);<br>Intent captureIntent = projectionManager.createScreenCaptureIntent();<br>startActivityForResult(captureIntent, REQUEST_CODE);</pre><p>Handle Configuration Changes for MediaProjection: Update VirtualDisplay for existing MediaProjection instances to handle configuration changes effectively.</p><pre>// Example of updating VirtualDisplay for configuration changes<br>virtualDisplay.resize(width, height);<br>virtualDisplay.setSurface(newSurface);</pre><p>Updated Non-SDK Restrictions: Android 14 includes updated lists of restricted non-SDK interfaces. Review your app’s usage of non-SDK interfaces and plan migration to SDK alternatives where necessary.</p><p>By implementing these adjustments, you ensure seamless compatibility and compliance with Android 14, enhancing both functionality and security for your React Native app users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcbb86598b51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Beyond Basics: A Deep Dive into Advanced Techniques]]></title>
            <link>https://medium.com/@dwslalit/javascript-beyond-basics-a-deep-dive-into-advanced-techniques-169d2fbf3df0?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/169d2fbf3df0</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[advanced-javascript]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Tue, 19 Dec 2023 05:40:28 GMT</pubDate>
            <atom:updated>2024-01-23T12:21:06.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ciy1lKEMSFXLzSOxStCeQQ.jpeg" /></figure><p>Welcome to our comprehensive exploration of advanced JavaScript concepts. In this blog series, we will delve into the intricacies of JavaScript, going beyond the basics to master advanced techniques that will elevate your coding skills. Each section of this series will focus on a specific advanced concept, providing a deep understanding, practical examples, and real-world applications.</p><h3>1. JavaScript Closures</h3><p>A closure is a powerful concept that involves a function and any other data the function can access from the outer lexical scope. Closures are functions that use variables from the outer lexical scope. They help with data encapsulation, removing redundancy, and maintaining modular code. Here’s an example:</p><pre>function createCaffeineAddict(coffeeType) {<br>    const addiction = `addicted to ${coffeeType}`;<br>    return function getHigh() {<br>        const highMessage = `Feeling wired and ${addiction}!`;<br>        console.log(highMessage);<br>    };<br>}</pre><pre>const espressoJunkie = createCaffeineAddict(&#39;espresso&#39;);<br>const latteLover = createCaffeineAddict(&#39;latte&#39;);<br>espressoJunkie();<br>latteLover();</pre><h3>2. JavaScript Inheritance</h3><p>JavaScript utilizes prototypal inheritance, where objects inherit properties and methods from each other through the Prototype Chain. Objects inherit methods from other objects, promoting code reusability. Here’s an example:</p><pre>function createCaffeineAddict(coffeeType) {<br>    const addiction = `addicted to ${coffeeType}`;<br>    return function getHigh() {<br>        const highMessage = `Feeling wired and ${addiction}!`;<br>        console.log(highMessage);<br>    };<br>}</pre><pre>const espressoJunkie = createCaffeineAddict(&#39;espresso&#39;);<br>const latteLover = createCaffeineAddict(&#39;latte&#39;);<br>espressoJunkie();<br>latteLover();</pre><h3>3. JavaScript Event Loops</h3><p>JavaScript operates on a single-threaded event loop in both browsers and Node.js. This mechanism allows non-blocking execution, crucial for handling modern web applications. Developers can deliberately queue tasks for execution in the next event loop iteration.</p><h3>4. JavaScript Callback Functions</h3><p>Callback functions are essential for handling asynchronous operations. They help manage the order of function execution, especially in scenarios involving time-consuming tasks. Here’s an example:</p><pre>function weightDisplayer(someWeight) {<br>    document.getElementById(&quot;display&quot;).innerHTML = someWeight + &quot; grams&quot;;<br>}</pre><pre>function calculateTotalWeight(arabicaWeight, robustaWeight, myCallback) {<br>    let totalWeight = arabicaWeight + robustaWeight;<br>    myCallback(totalWeight);<br>}</pre><pre>calculateTotalWeight(500, 250, weightDisplayer);</pre><h3>5. JavaScript Async/Await and Promises</h3><p>Async/Await and Promises enhance asynchronous programming in JavaScript. Async functions are perfect for tasks like fetching data from an API or reading a file. They automatically return a promise, and the await keyword allows pausing execution until promises resolve. Here&#39;s an example:</p><pre>async function prepareCoffee() {<br>    try {<br>        const beans = await fetch(&#39;https://example.com/api/beans&#39;);<br>        const groundBeans = await grindBeans(beans);<br>        const brewedCoffee = await brewCoffee(groundBeans);<br>        return brewedCoffee;<br>    } catch (error) {<br>        console.error(error);<br>    }<br>}</pre><pre>const myCoffee = prepareCoffee();<br>console.log(myCoffee);</pre><h3>6. JavaScript Functional Programming</h3><p>Functional programming in JavaScript encourages the use of pure functions, immutability, and high-order functions. Here’s an example:</p><pre>const coffee = {<br>    type: &#39;Arabica&#39;,<br>    roast: &#39;dark&#39;,<br>    hasCaffeine: true,<br>    aroma: {<br>        notes: [&#39;chocolate&#39;, &#39;nutty&#39;, &#39;spicy&#39;]<br>    }<br>};</pre><pre>const addAromaNote = (coffeeObj, note) =&gt; ({<br>    ...coffeeObj,<br>    aroma: {<br>        ...coffeeObj.aroma,<br>        notes: [...coffeeObj.aroma.notes, note]<br>    }<br>});</pre><pre>const newCoffee = addAromaNote(coffee, &#39;fruity&#39;);<br>console.log(newCoffee.aroma.notes); // [&#39;chocolate&#39;, &#39;nutty&#39;, &#39;spicy&#39;, &#39;fruity&#39;]<br>console.log(coffee.aroma.notes); // [&#39;chocolate&#39;, &#39;nutty&#39;, &#39;spicy&#39;]</pre><h3>7. JavaScript High-Order Functions</h3><p>High-order functions take one or multiple functions as parameters or return a function. They improve code readability and reusability. Examples include reduce(), map(), filter(), and sort().</p><h4>A. JavaScript Reduce()</h4><p>Reduce is a powerful method that accumulates array elements, returning a single value.</p><h4>B. JavaScript Map()</h4><p>Map transforms each array element, returning a new identical array.</p><h4>C. JavaScript Filter()</h4><p>Filter creates a new array with elements that pass a specific condition.</p><h4>D. JavaScript Sort()</h4><p>Sort overwrites an array by sorting its elements.</p><h3>8. JavaScript Generators</h3><p>Generators are special functions that can pause and resume. They provide a new way to interact with iterators and regular functions. Here’s an example:</p><pre>function* coffeeGenerator() {<br>    const coffeeTypes = [&#39;latte&#39;, &#39;cappuccino&#39;, &#39;espresso&#39;, &#39;americano&#39;];<br>    for (let i = 0; i &lt; coffeeTypes.length; i++) {<br>        yield coffeeTypes[i];<br>    }<br>}</pre><pre>const coffee = coffeeGenerator();<br>console.log(coffee.next().value); // latte<br>console.log(coffee.next().value); // cappuccino<br>console.log(coffee.next().value); // espresso<br>console.log(coffee.next().value); // americano</pre><h3>9. JavaScript Hoisting</h3><p>Hoisting allows you to declare variables and functions after their assignment. It applies to variables and functions defined with var and function. Here&#39;s an example:</p><pre>var coffeeBlend;<br>console.log(coffeeBlend);<br>coffeeBlend = &quot;Dark Roast&quot;;</pre><pre>function brewCoffee() {<br>    console.log(&quot;Brewing a fresh pot of coffee!&quot;);<br>}</pre><pre>brewCoffee();</pre><h3>10. JavaScript IIFEs</h3><p>IIFEs (Invoked Function Expressions) are functions executed immediately after being created. They are useful for avoiding global scope pollution. Here’s an example:</p><pre>(function(coffeeType) {<br>    console.log(&quot;Brewing a fresh pot of &quot; + coffeeType + &quot; coffee!&quot;);<br>})(&quot;French roast&quot;);</pre><h3>11. JavaScript Memoization</h3><p>Memoization is crucial for optimizing web apps by caching function results based on input arguments. It improves performance by avoiding redundant calculations. Here’s an example:</p><pre>function multiply(x, y) {<br>    return x * y;<br>}</pre><pre>const cache = {};</pre><pre>function memoizedMultiply(x, y) {<br>    const cacheKey = x + &quot;:&quot; + y;<br>    if (cache[cacheKey] !== undefined) {<br>        return cache[cacheKey];<br>    } else {<br>        const result = multiply(x, y);<br>        cache[cacheKey] = result;<br>        return result;<br>    }<br>}</pre><pre>console.log(memoizedMultiply(2, 3)); // Should print &quot;6&quot;<br>console.log(memoizedMultiply(2, 3)); // Should print &quot;6&quot; again (result is already memoized)</pre><h3>12. JavaScript Currying</h3><p>Currying transforms a function that takes multiple arguments into a sequence of functions, each taking a single argument. Here’s an example:</p><pre>function brewCoffee(beans) {<br>    return function(water) {<br>        return beans * water;<br>    }<br>}</pre><pre>const coffeeMaker = brew</pre><h3>Conclusion:</h3><p>Wrap up the blog series by summarizing key takeaways and encouraging readers to explore more advanced JavaScript concepts.</p><p>Thank you for joining us on this odyssey through the intricacies of advanced JavaScript concepts. May your coding endeavors be marked by creativity, efficiency, and a deep appreciation for the art of web development. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=169d2fbf3df0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing React Native: The Power of Bridgeless Mode]]></title>
            <link>https://medium.com/@dwslalit/optimizing-react-native-the-power-of-bridgeless-mode-c4fe405683f6?source=rss-375810cbf7d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4fe405683f6</guid>
            <dc:creator><![CDATA[Lalit Suthar]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 08:55:38 GMT</pubDate>
            <atom:updated>2024-06-28T07:14:50.824Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-evolving world of mobile app development, React Native continues to be a go-to framework for building cross-platform applications. With each iteration, React Native introduces innovations to enhance performance and developer experience. One such game-changing feature is Bridgeless Mode.</p><h3>Understanding Bridgeless Mode</h3><p>Before diving into the benefits and implementation of Bridgeless Mode, let’s grasp the concept. Traditionally, React Native relied on a bridge to facilitate communication between JavaScript and native modules. However, this bridge introduced limitations in terms of asynchronous design, message batching, and serialization costs.</p><p>The New Architecture initiative aimed to remove React Native’s dependency on the bridge. TurboModules and Fabric were introduced to move native calls and component rendering off the bridge. Now, with Bridgeless Mode, the entire React Native runtime, including error handling, global event emitters, timers, and more, are moved off the bridge.</p><h3>What Bridgeless Mode Offers</h3><ol><li>Support for Legacy Native Modules:<br>In the absence of the bridge, an interoperability layer has been introduced to continue supporting legacy native modules. This ensures a smooth transition to the new native module system (TurboModules).</li><li>Static ViewConfigs for Optimized Rendering:<br>Bridgeless Mode optimizes component rendering with Static ViewConfigs. This shift to build-time analysis, based on a native component’s Flow or TypeScript spec file, enhances efficiency.</li></ol><h3>Enabling Bridgeless Mode</h3><p>To unlock the potential of Bridgeless Mode, follow these steps:</p><h3>Prerequisites:</h3><ul><li>Migrate to React Native 0.73</li></ul><h3>1. Update Static ViewConfig Babel Plugin:</h3><p>If your project relies on it, update it to @react-native/babel-preset@0.73.18. Refer to &quot;v0.73 Release Notes/Babel Package Renames&quot; for details.</p><h3>2. Enable Bridgeless Flag in Native:</h3><h4>Android</h4><p>In your MainApplication.kt file, update the onCreate function:</p><pre>import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load</pre><pre>override fun onCreate() {<br>  ...<br>  if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {<br>    load(bridgelessEnabled = true)<br>  }<br>  ...<br>}</pre><h4>iOS</h4><p>Override the bridgelessEnabled function in your app’s AppDelegate.mm:</p><pre>// AppDelegate.mm<br>- (BOOL)bridgelessEnabled {<br>    return YES;<br>}</pre><h3>3. Migrate Legacy APIs:</h3><p>Review and migrate legacy APIs, especially callable JavaScript modules and native module calls. Ensure compatibility with the new architecture.</p><p>JavaScript:</p><p>Before:</p><pre>BatchedBridge.registerCallableModule(&#39;FooModule&#39;, FooModule);</pre><p>After:</p><pre>global.RN$registerCallableModule(&#39;FooModule&#39;, () =&gt; FooModule);</pre><p>Android:</p><p>Replace calls on the bridge with reactContext directly.</p><p>iOS:</p><p>Certain APIs that returned a bridge will now return a “bridge look-a-like” (RCTBridgeProxy) object.</p><h3>Conclusion</h3><p>Bridgeless Mode marks a significant stride in the evolution of React Native, addressing performance bottlenecks associated with the traditional bridge. By following these steps, you can seamlessly migrate to Bridgeless Mode and take full advantage of its efficiency improvements.</p><p>Stay tuned for a more responsive and streamlined React Native development experience!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4fe405683f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>