<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rushit Jivani</title>
    <description>The latest articles on DEV Community by Rushit Jivani (@rushitjivani).</description>
    <link>https://dev.to/rushitjivani</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1091418%2F7cac2a2d-fc00-4982-9f75-eaf017790800.jpeg</url>
      <title>DEV Community: Rushit Jivani</title>
      <link>https://dev.to/rushitjivani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rushitjivani"/>
    <language>en</language>
    <item>
      <title>React Context: The Ultimate Handbook</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Wed, 03 Jan 2024 12:12:11 +0000</pubDate>
      <link>https://dev.to/rushitjivani/react-context-the-ultimate-handbook-418f</link>
      <guid>https://dev.to/rushitjivani/react-context-the-ultimate-handbook-418f</guid>
      <description>&lt;p&gt;Years ago, the Context API was introduced as an experimental feature with a warning “in the future this API can break”. As the Context API was experimental, most React developers were not confident enough to use it.&lt;/p&gt;

&lt;p&gt;But after the release of React v16.3, we get the new Context API, which brings enhanced efficiency and is fully prepared for production. and now it’s one of the Important React Concepts.&lt;/p&gt;

&lt;p&gt;In this comprehensive guide, we will explore the concept of React context, its implementation, and guidelines for its proper usage in various scenarios. Additionally, we will discuss the dos and don’ts of utilizing context effectively to maximize its benefits.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is React context?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React context is a way to easily share and access data across different components in our React application, without the need for prop drilling.&lt;/p&gt;

&lt;p&gt;Think of context as a global object accessible within a specific subtree of React components.&lt;/p&gt;

&lt;p&gt;Why this Context API is so important?&lt;br&gt;
In React, components are organized in a hierarchical structure resembling a tree. The topmost component is the root node, and all other components are connected to it. Data in this structure flows in a single direction, from the top down.&lt;/p&gt;

&lt;p&gt;For instance, let’s consider this app where both ShopDisplay and Cart need access to the items a user has put into their shopping cart. We can pass props down into the Shop Display component and Cart component so that they have access to &lt;em&gt;cartItems&lt;/em&gt; and &lt;em&gt;setCartItems&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function App() {
  const [cartItems, setCartItems] = useState([]);

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;ShopDisplay handleCartItems={setCartItems} /&amp;gt;
      &amp;lt;Cart cartItems={cartItems} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here as you can see what is happening above:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;App — Has access to both &lt;code&gt;cartltems&lt;/code&gt; and &lt;code&gt;setCartltems&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;ShopDisplay — Has access to &lt;code&gt;setCartltems&lt;/code&gt; via props&lt;/li&gt;
&lt;li&gt;Cart — Has access to &lt;code&gt;cartltems&lt;/code&gt; via props&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Prop drilling can be somewhat like a Russian nesting doll with several layers of props going further and further into child components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UQUDSNoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvinyddg3ls300rj4p1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UQUDSNoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvinyddg3ls300rj4p1w.png" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the &lt;em&gt;Cart&lt;/em&gt; component can also pass down &lt;code&gt;cartItems&lt;/code&gt; to any child components it has.&lt;/p&gt;

&lt;p&gt;In React, data only flows in one direction. So, if you need data at a deep level in your component tree, you have to pass it down as a prop through all the child components. This can be a lot of work, so people use state management libraries like Redux or MobX to make it easier. If you’ve used either of these libraries, you’ve already used the Context API indirectly. That’s because Redux uses the Context API internally.&lt;/p&gt;

&lt;p&gt;This is a picture that shows how context can be used to share data with all the components in a React app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bABvPQXf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ar0k2w9gow4uvp58ygqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bABvPQXf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ar0k2w9gow4uvp58ygqq.png" alt="Image description" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When should you use React context?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want to share data with many components at different nesting levels. Like Theming (like dark or light mode), User data (the currently authenticated user), Multilingual Support (like user language or locale), and application configuration (like base URL).&lt;/li&gt;
&lt;li&gt;When the same prop (data) is passed through several components.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Or-kecZ7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1wc1l1ovebhy6p7bcpt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Or-kecZ7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1wc1l1ovebhy6p7bcpt.png" alt="Image description" width="800" height="1540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I use React context?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using the context in React requires 3 simple steps: creating the context, providing the context, and consuming the context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. Creating the context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The built-in factory function &lt;code&gt;createContext(default)&lt;/code&gt; creates a context instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// context.js
import { createContext } from 'react';

export const Context = createContext('Default Value');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The factory function accepts one optional argument: the default value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. Providing the context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Context.Provider&lt;/code&gt; component available on the context instance is used to provide the context to its child components, no matter how deep they are.&lt;/p&gt;

&lt;p&gt;To set the value of context use the &lt;code&gt;value&lt;/code&gt; prop available on the &lt;code&gt;&amp;lt;Context.Provider value={value} /&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Context } from './context';

function Main() {
  const value = 'My Context Value';
  return (
    &amp;lt;Context.Provider value={value}&amp;gt;
      &amp;lt;MyComponent /&amp;gt;
    &amp;lt;/Context.Provider&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, what’s important here is that all the components that’d like later to consume the context have to be wrapped inside the provider component.&lt;/p&gt;

&lt;p&gt;If you want to change the context &lt;code&gt;value&lt;/code&gt;, simply update the value prop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C. Consuming the context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consuming the context can be performed by the &lt;code&gt;useContext(Context)&lt;/code&gt; React hook:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useContext } from 'react';
import { Context } from './context';

function MyComponent() {
  const value = useContext(Context);

  return &amp;lt;span&amp;gt;{value}&amp;lt;/span&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check out the demo &lt;a href="https://codesandbox.io/s/react-context-consumer-f413s?file=%2Fsrc%2FMain.js"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does React context replace Redux?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Absolutely! And well, not quite.&lt;/p&gt;

&lt;p&gt;For React beginners, Redux simplifies data sharing. Redux is bundled with React context, which enables easier passing of data.&lt;/p&gt;

&lt;p&gt;However, if you’re not modifying the state and just passing it down your component tree, you don’t require Redux, a global state management library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to update the context value?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The React Context API doesn’t have a built-in way to update the context value from consumer components since it’s primarily designed to be stateless.&lt;/p&gt;

&lt;p&gt;However, you can easily achieve this by incorporating a state management approach, such as using the &lt;code&gt;useState()&lt;/code&gt; or &lt;code&gt;useReducer()&lt;/code&gt; hooks. By doing so, you can provide an update function alongside the value in the context.&lt;/p&gt;

&lt;p&gt;Although, it’s generally not recommended to update the context value due to performance concerns. and this leads us to the limitations of React context.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Read &lt;a href="https://dmitripavlutin.com/react-context-and-usecontext/#a-creating-the-context"&gt;this awesome blog&lt;/a&gt; about how to use and update the context.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;React context limitations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s understand it by example. Suppose you’re passing down an object through your React context provider, and one of its properties gets updated. What happens next? Well, any component that consumes that context will re-render.&lt;/p&gt;

&lt;p&gt;Now, this might not pose a performance problem in smaller applications with only a few state values that don’t change frequently (like theme data). However, it becomes problematic when you have numerous components in your component tree and need to perform multiple state updates.&lt;/p&gt;

&lt;p&gt;A workaround for this is by creating a separate Context/Provider for each functional section that needs to share data among its components. This approach helps minimize the number of components that need to be rendered, as updates will only occur within specific sub-trees of your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Great job! By learning Context API, you’ve added a valuable skill to your toolkit. Now you can pass the value of the first component to the last component without disturbing the other components.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of claps! 👏&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please leave a comment with your feedback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev.to&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/"&gt;LinkedIn&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Unlocking the Impossible: Search Keywords Within WebView in React Native</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Tue, 12 Dec 2023 09:31:12 +0000</pubDate>
      <link>https://dev.to/rushitjivani/unlocking-the-impossible-search-keywords-within-webview-in-react-native-2led</link>
      <guid>https://dev.to/rushitjivani/unlocking-the-impossible-search-keywords-within-webview-in-react-native-2led</guid>
      <description>&lt;p&gt;When you’re looking for a specific phrase or word on a web page, the last thing you want to do is go through the entire page for that word. Searching for a word on a web page is a great way to save time.&lt;/p&gt;

&lt;p&gt;In this article, you’ll find instructions on how to search for words on a WebView in React Native.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Search for a Word Using a Web Browser&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to search for a specific word in a web browser, you can perform this task using your keyboard shortcuts. To access your search shortcuts, here’s what you need to do:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to the web page you want to search through.&lt;/li&gt;
&lt;li&gt;Use the Control + F keywords on your PC, or Command + F on Mac.&lt;/li&gt;
&lt;li&gt;The find bar will show up in the top-right corner or at the bottom of your screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zjaE0Roh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ck5iyvst9828mlubr1j9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zjaE0Roh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ck5iyvst9828mlubr1j9.gif" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the word you want to search for, and the word will be highlighted across the web page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Searching for a Word in React Native’s WebView&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, you must know that web view is not a component inside the react-native core, so we need to install the package.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install react-native-webview&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After that, we can use the web-view&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LNH23XfG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qalff8rq4f6uc4pchdl3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LNH23XfG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qalff8rq4f6uc4pchdl3.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if you ever work with native Android web view then you will find it is very easy to integrate &lt;strong&gt;Search Functionality&lt;/strong&gt;. The native Android WebView offers built-in functions like &lt;code&gt;findall()&lt;/code&gt; and &lt;code&gt;findnext()&lt;/code&gt; that make integrating search features a breeze.&lt;/p&gt;

&lt;p&gt;But if you look into the &lt;code&gt;react-native-webview&lt;/code&gt; API &lt;a href="https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md"&gt;documentation&lt;/a&gt; then you’ll find there are no props, no API, or no built-in functions that help you to integrate such functionality.&lt;/p&gt;

&lt;p&gt;So, How can we achieve this? 🤔&lt;/p&gt;

&lt;p&gt;Are there any other properties or functions we can use to achieve this?&lt;/p&gt;

&lt;p&gt;The answer is Yes, we can use &lt;code&gt;injectJavaScript&lt;/code&gt; Method to implement this functionality.&lt;/p&gt;

&lt;p&gt;Ok, now we have a way to achieve this, but what about the bridge or support that carries out the search and highlights the keyword functionality in the webView?&lt;/p&gt;

&lt;p&gt;In this case, we’re using &lt;code&gt;mark.js&lt;/code&gt; script, which helps us search for specific words and highlight them.&lt;/p&gt;

&lt;p&gt;Okay, now that our roadmap is prepared, let’s explore the essential functions and their functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zGELqX4C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjxoe2i9x3yfx3kqteab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zGELqX4C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjxoe2i9x3yfx3kqteab.png" alt="Image description" width="800" height="1731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are 3 major functions that are used to implement the functionality&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;searchKeyword — triggered by the onChangeText event on React Native TextInput.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w1jAqooE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ngrbxos0p6v2sdhfjit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w1jAqooE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ngrbxos0p6v2sdhfjit.png" alt="Image description" width="800" height="671"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.focusNext and focusPrevious — activated when the next and previous buttons are pressed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JHK8Vw-V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjo99l39jrpngw7gh4js.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JHK8Vw-V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjo99l39jrpngw7gh4js.png" alt="Image description" width="800" height="991"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.jumpTo — triggered when the next and previous buttons are pressed to highlight the major next and previous keywords.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8mni0z_A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1ptdc7ah1j4oscyj21h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8mni0z_A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1ptdc7ah1j4oscyj21h.png" alt="Image description" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, that’s it. 🎉 Run the code to see it in action.🥳&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Please check out this sample &lt;a href="https://github.com/Rushit013/RNWebSearch"&gt;project on GitHub&lt;/a&gt; for more information&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of claps! 👏&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please leave a comment with your feedback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev.to&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/"&gt;LinkedIn&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Boost Your Developer Productivity with These 5 Must-Know Tips!</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Mon, 28 Aug 2023 13:21:07 +0000</pubDate>
      <link>https://dev.to/rushitjivani/boost-your-developer-productivity-with-these-5-must-know-tips-96m</link>
      <guid>https://dev.to/rushitjivani/boost-your-developer-productivity-with-these-5-must-know-tips-96m</guid>
      <description>&lt;p&gt;Being productive is an essential skill for your success as a developer.&lt;/p&gt;

&lt;p&gt;A developer who possesses a strong work ethic not only demonstrates increased productivity but also contributes positive energy to the workplace — which has a direct impact on the team’s overall performance. This serves as a valuable indicator of the ultimate outcome of the product.&lt;/p&gt;

&lt;p&gt;Being a productive developer has its perks — higher pays for getting quality work done in less time, better work-life balance, and, of course, an internal satisfaction.&lt;/p&gt;

&lt;p&gt;To maintain productivity over a long period, it’s important to embrace specific work ethics and habits that gradually become ingrained in your daily routine. These practices will help you stay on track and accomplish your goals with ease.&lt;/p&gt;

&lt;p&gt;Let’s walk through some effective ways to make your work and life as a developer productive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 1: Master the Fundamentals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---ORRE_Ep--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwzydn7rvv8avqpfz3t3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---ORRE_Ep--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwzydn7rvv8avqpfz3t3.gif" alt="Image description" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many beginners tend to quickly browse through the basics and assume that the real excitement lies in advanced topics. However, they often give up prematurely, claiming that these advanced subjects are excessively challenging. It’s important to understand that without a solid foundation in the fundamentals, comprehending advanced topics can appear unattainable.&lt;/p&gt;

&lt;p&gt;Therefore, even though the fundamentals may initially seem uninteresting or insignificant, they play a vital role in your learning journey. Embracing the basics is an initial investment that will bring significant rewards in the long term, something your future self will greatly appreciate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 2: Implement it by reading documents or articles, NOT Watching Videos&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developing practical skills is essential for success in a programming career. I’ve noticed many beginners who watch tutorials and assume they have the required skills.&lt;/p&gt;

&lt;p&gt;Theoretical knowledge alone is of no value unless you can effectively apply it to real-world programming. Learning comes from hands-on experience, not just studying and not just watching videos.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ik2yxfwW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iexqcwjjz45bihqk0cs2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ik2yxfwW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iexqcwjjz45bihqk0cs2.png" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s important to stay resilient and not let discouragement easily take hold. When you tackle difficult challenges directly, it’s natural for the process to take time before you experience a significant breakthrough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 3: Divide Large And Complex Tasks Into Smaller Tasks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Divide the large complex task into smaller parts, don’t think much about the complex problem, — Just break it down and try to solve a small portion of it, by the end, you’ll see that it’s all done! Most of the developers waste their time thinking about the bigger task and got demotivated. Take it easy, start executing the small task, you can achieve the goal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9R5XDdxN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwwy9x9s9kn3urh2128a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9R5XDdxN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwwy9x9s9kn3urh2128a.png" alt="Image description" width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 4: Errors can be valuable allies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No matter how skilled you are as a developer, encountering errors is a regular part of your journey. Sometimes you fix them right away, and oftentimes you do it after reviewing your code and You wish they never happened.&lt;/p&gt;

&lt;p&gt;But Rather than becoming frustrated, take a moment to go through the error message. You’ll often find a clear indication of what’s causing the issue, which can help you resolve it swiftly and easily.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dTNLPv1c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xl3isczjnh4x1ja0dkjb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dTNLPv1c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xl3isczjnh4x1ja0dkjb.png" alt="Image description" width="610" height="850"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learning to &lt;strong&gt;debug an application&lt;/strong&gt; is simply the most important skill to master to &lt;em&gt;level up your programming skills&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 5: Know your development environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The more aware of the weapons in your arsenal, the easier it will be to kill the enemy. To be clear, the enemy is the distractions that break your workflow. To maintain productivity, it’s important to minimize the time spent on researching libraries or tools for your project and stay focused on the task at hand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_85UmqFW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lx2oz55rczfmkfhyerow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_85UmqFW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lx2oz55rczfmkfhyerow.png" alt="Image description" width="690" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To improve productivity, &lt;strong&gt;learn all the code editor shortcuts&lt;/strong&gt; and use them in your work — it will save you both time and effort in the long run. Take your time to explore different tools, frameworks, and libraries to choose the best option based on your project requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip 6: Taking Breaks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers often find themselves surrounded with a pile of work and deadlines which lead to longer working hours, without breaks.&lt;/p&gt;

&lt;p&gt;There are enough &lt;a href="https://www.sciencedaily.com/releases/2011/02/110208131529.htm"&gt;studies&lt;/a&gt; to support that taking breaks between work leads to higher productivity. It’s important to realize in order to keep up with focus and concentration levels, the mind needs a break from time to time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4T3MVhRe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/japmgjjr0n22k8lto23t.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4T3MVhRe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/japmgjjr0n22k8lto23t.gif" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A couple of ways to remind yourself it’s a time for a break are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Pomodoro Technique&lt;/strong&gt;: Setting timers help in dividing your goals and time management. As a result, your problem-solving skills improve drastically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Drink water&lt;/strong&gt;: Keeping yourself hydrated at work helps you stay fresh and prevents exhaustion. Moreover, it’s a good incentive to take a walk.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope you find the above tips useful in improving your productivity as a developer.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of claps! 👏&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please leave a comment with your feedback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev.to&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/"&gt;LinkedIn&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Boost your SEO: Best Practices and Strategies</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Mon, 21 Aug 2023 05:36:20 +0000</pubDate>
      <link>https://dev.to/rushitjivani/boost-your-seo-best-practices-and-strategies-2hj4</link>
      <guid>https://dev.to/rushitjivani/boost-your-seo-best-practices-and-strategies-2hj4</guid>
      <description>&lt;p&gt;Over 80% of searches are conducted using search engines. It’s interesting to note that the typical internet user tends to focus on the first five results displayed on a search engine results page (SERP). A study conducted in 2014 by Advanced Web Rankings revealed that approximately 67% of all clicks on SERPs are directed towards those top five listings. As of 2019, this percentage has risen significantly to 94.53%.&lt;/p&gt;

&lt;p&gt;So SEO; Search Engine Optimization, is all about ensuring that your web page achieves a good ranking on search engines, particularly Google. It’s worth noting that according to Net Market Share, Google holds a significant 81.64% share of the Search Engine Market. So, optimizing your website for Google can greatly enhance its visibility and reach.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--09wF2ZW4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvtxbnn7o7ep8jiljrbc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--09wF2ZW4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xvtxbnn7o7ep8jiljrbc.png" alt="Image description" width="738" height="996"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are a few tips that can significantly boost your &lt;strong&gt;SEO&lt;/strong&gt; and help you rank higher on any &lt;strong&gt;Search Engine&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Metadata&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Meta Tags&lt;/strong&gt; define the &lt;strong&gt;&lt;em&gt;metadata&lt;/em&gt;&lt;/strong&gt; for the page and also enable you to add additional details to your website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MLEycGUF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwaa96i0suwql8xm3n0z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MLEycGUF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwaa96i0suwql8xm3n0z.png" alt="Image description" width="669" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Metadata won’t appear on the webpage itself, but it’s formatted for machines to understand. Browsers, search engines (like Google), and other web services can utilize this information.&lt;/p&gt;

&lt;p&gt;Here are a few commonly used Meta Tags that you should definitely consider including. Simply fill in the required details and add them to the head section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- Basic SEO --&amp;gt;
&amp;lt;meta httpEquiv="cache-control" content="max-age=&amp;lt;age in seconds&amp;gt;" /&amp;gt;
&amp;lt;meta charset="utf-8" /&amp;gt;
&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1" /&amp;gt;
&amp;lt;meta name="theme-color" content="&amp;lt;theme color hex&amp;gt;" /&amp;gt;
&amp;lt;meta name="keywords" content="comma separated keywords" /&amp;gt;
&amp;lt;meta httpEquiv="Content-Type" content="text/html; charset=utf-8" /&amp;gt;
&amp;lt;meta name="language" content="English" /&amp;gt;

&amp;lt;meta name="description" content="&amp;lt;description&amp;gt;" /&amp;gt;
&amp;lt;meta name="image" content="/image-link.png" /&amp;gt;
&amp;lt;meta name="thumbnail" content="/image-link.png" /&amp;gt;
&amp;lt;meta name="title" content="&amp;lt;title&amp;gt;" /&amp;gt;
&amp;lt;!-- Schema.org for Google+ --&amp;gt;
&amp;lt;meta itemprop="description" content="&amp;lt;description&amp;gt;" /&amp;gt;
&amp;lt;meta itemprop="image" content="/image-link.png" /&amp;gt;
&amp;lt;meta itemprop="name" content="&amp;lt;title&amp;gt;" /&amp;gt;
&amp;lt;!-- Twitter  --&amp;gt;
&amp;lt;meta name="twitter:card" content="summary" /&amp;gt;
&amp;lt;meta name="twitter:description" content="&amp;lt;description&amp;gt;" /&amp;gt;
&amp;lt;meta name="twitter:image" content="/image-link.png" /&amp;gt;
&amp;lt;meta name="twitter:title" content="&amp;lt;title&amp;gt;" /&amp;gt;
&amp;lt;!-- Open Graph general (Facebook, Pinterest &amp;amp; Google+) --&amp;gt;
&amp;lt;meta property="og:description" content="&amp;lt;description&amp;gt;" /&amp;gt;
&amp;lt;meta property="og:image" content="/image-link.png" /&amp;gt;
&amp;lt;meta property="og:site_name" content="&amp;lt;site name&amp;gt;" /&amp;gt;
&amp;lt;meta property="og:title" content="&amp;lt;title&amp;gt;" /&amp;gt;
&amp;lt;meta property="og:type" content="website" /&amp;gt;
&amp;lt;meta property="og:url" content="&amp;lt;url for the website&amp;gt;" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Load Time and User Experience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HzuOegsR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ifmuu02qskg85b1udq2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HzuOegsR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ifmuu02qskg85b1udq2.png" alt="Image description" width="800" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember people are impatient, The stats are shocking.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://blog.kissmetrics.com/loading-time/?wide=1"&gt;25% of users&lt;/a&gt; will have left your site after only 4 seconds of loading time.&lt;br&gt;
That’s one-fourth of your prospective leads gone in just four seconds…&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Website load time is a crucial factor in your users’ experience. And, Google started tracking page speed in 2018.&lt;/p&gt;

&lt;p&gt;Your web page load times are directly related to design.&lt;/p&gt;

&lt;p&gt;Websites featuring complex graphics, many photos (think online shopping), or videos take longer to load.&lt;/p&gt;

&lt;p&gt;You can reduce the page load time by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce unused JavaScript.&lt;/li&gt;
&lt;li&gt;Eliminate render-blocking resources.&lt;/li&gt;
&lt;li&gt;Reduce initial server response time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Use appropriate keywords In The Right Places&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keywords are terms or expressions that describe the content of your website. They allow search engines to understand the subject of your site and to display relevant results for Internet users. It is therefore important to choose &lt;a href="https://optinmonster.com/using-keywords-to-improve-your-seo/#:~:text=Part%20of%20the%20SEO%20process,web%20page%20its%20search%20ranking."&gt;your keywords&lt;/a&gt; well and to use them strategically in the right place.&lt;/p&gt;

&lt;p&gt;Ensure your keyword appears in the page title.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--va4-gye3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u8prf8xli0c59n21j304.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--va4-gye3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u8prf8xli0c59n21j304.png" alt="Image description" width="754" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Webpage URL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LHNIfGEW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7vhg0at5rrmhtlu36sc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LHNIfGEW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7vhg0at5rrmhtlu36sc.png" alt="Image description" width="753" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in the first 100 words of your content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Dc-l9e5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fxxvqqr6814j5bta72b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Dc-l9e5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7fxxvqqr6814j5bta72b.png" alt="Image description" width="753" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Provide useful and fresh content&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It’s common for content to come last in the web design process, but that is a mistake. In SEO, content is king! Content is the new SEO these days. Now, you might have some ideas about how important content is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S5O7QCJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddvmchx0ean68bqaz7o1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S5O7QCJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddvmchx0ean68bqaz7o1.png" alt="Image description" width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your content is static, old, or out of date then most probably your visitors will go away quickly and never come back.&lt;/p&gt;

&lt;p&gt;There is big competition in every keyword you search and those websites that have the most useful and fresh content, have more chances of winning the race.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Don’t forget the fundamentals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KXboOdvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z18wutt2jr68cbw4jzkx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KXboOdvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z18wutt2jr68cbw4jzkx.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just like a strong house requires a solid foundation, achieving overall website optimization is impossible without following best practices in application development. Well organised, minimal code is the key.&lt;/p&gt;

&lt;p&gt;That’s it and you’re on your way to skyrocketing your website SEO.&lt;/p&gt;

&lt;p&gt;Summing Up by an interesting quote from &lt;em&gt;Wendy Piersall&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Google only loves you when everyone else loves you first.” – &lt;strong&gt;Wendy Piersall&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;




&lt;p&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of claps! 👏&lt;/p&gt;

&lt;p&gt;Please leave a comment with your feedback.&lt;/p&gt;

&lt;p&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev.to&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>seo</category>
      <category>learning</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Master the Art of Clean Code: A practical approach</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Mon, 14 Aug 2023 05:44:21 +0000</pubDate>
      <link>https://dev.to/rushitjivani/master-the-art-of-clean-code-a-practical-approach-57n4</link>
      <guid>https://dev.to/rushitjivani/master-the-art-of-clean-code-a-practical-approach-57n4</guid>
      <description>&lt;p&gt;We often discuss various architectures, but there are other important and simple things that can be done to keep code clean and manageable in the long run. In this article, we’re going to examine what good code is, and what qualities of good code are. That’s because those qualities come before programming principles. Programming principles are just guidelines to help us apply those qualities to code.&lt;/p&gt;

&lt;p&gt;Developers not only write code but also dedicate a considerable amount of time to reading it. In fact, reading code often surpasses the time spent on actual coding.&lt;/p&gt;

&lt;p&gt;Have you ever considered how frequently you review the code you’ve just written? Obviously, the ratio is in favor of reading than actual coding.&lt;/p&gt;

&lt;p&gt;If we spend a significant amount of time understanding and reading code, it is important to ensure that our own code is clear and easily understood by our colleagues.&lt;/p&gt;

&lt;p&gt;So here are 5 tips that can help keep you from being that programmer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use Meaningful variable Names&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Everywhere we code, we have the control to choose meaningful names: variables, functions, classes, packages, files…Taking it seriously is the first step to having Clean Code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// BAD
let days;// elapsed time in days

// CLEAN 
let daysSinceCreation;
let daysSinceUpdate;
let ageInDays;
let elapsedDays;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the case of &lt;strong&gt;booleans&lt;/strong&gt;, the variable name should be a question that can be answered with &lt;em&gt;yes or no&lt;/em&gt;, such as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const isValid = false;
const hasAuthorization = true;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Write code that expresses intent&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Having clear and distinct names for variables and functions is crucial to avoid confusion and ensure their intended context and meaning. So when you are writing a function you should remember two things to make your function clean and easy to understand…&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;They should be small.&lt;/li&gt;
&lt;li&gt;They should do only one thing and they should do it well.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s look at an example of good naming:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getActiveAccount(studentId){                  
     // ...
}
function getActiveAccountInfo(studentId){ 
     // ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Select a naming style and stick with it consistently. Whether it’s &lt;code&gt;camelCase&lt;/code&gt; or &lt;code&gt;under_scores&lt;/code&gt;, choose one that suits you best and use it throughout your code.&lt;/p&gt;

&lt;p&gt;Give your functions, methods, and variables names based on their purpose or characteristics. If a method retrieves something, include “get” in its name. Similarly, if a variable holds the gender of a user, name it &lt;code&gt;userGender&lt;/code&gt; for example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: If you find it challenging to name your function, it may be a sign that it’s trying to do too many things at once. In such cases, it’s a good idea to break it down into smaller, more focused functions. In such case, you can use these 2 principles.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The function body should not contain more than 2 levels of nesting&lt;/li&gt;
&lt;li&gt;A function should take a maximum of 3 arguments&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Group Similar Functions Together&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As your projects grow in size, it’s common to have numerous functions. To maintain a well-organized codebase, it’s recommended to keep all your function declarations at the top of the page or grouped together in one place. This practice not only helps improve code readability but also enhances search efficiency. By doing so, you can easily locate and access the function you need, making your coding experience smoother and more efficient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function read_data(file_name) {
  // ..
}

export function write_data(file_name) {
  // ..
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { read_data, write_data } from './utils.js';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now call the utility functions within the component.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Express yourself in code rather than in comments&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is a saying, “Code should be self-documenting”, which basically means, instead of using comments, your code should read well enough to reduce the need for comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POV&lt;/strong&gt;: Comments are often lies waiting to happen. eg: You added new features and forgot to change previous comments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ven9j9n4qy9msogueri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ven9j9n4qy9msogueri.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use consistent formatting &amp;amp; indentation&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think of code as an article, where consistency is key. Just like an article with inconsistent line spacing, varying font sizes, and scattered line breaks can be hard to read, the same holds true for your code.&lt;/p&gt;

&lt;p&gt;To ensure clarity and readability, it’s important to maintain a consistent and organized structure in your code. By using formatter like &lt;a href="https://pypi.org/project/black/" rel="noopener noreferrer"&gt;black&lt;/a&gt; or &lt;a href="https://prettier.io/" rel="noopener noreferrer"&gt;prettier&lt;/a&gt; you can automate the formatting.&lt;/p&gt;

&lt;p&gt;There is a famous quote from Bill Gates, it goes like&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;“If you can’t make it good, at least make it look good”&lt;/em&gt;&lt;/strong&gt; — &lt;strong&gt;&lt;em&gt;Bill Gates&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s a good and bad example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Good&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function testNum(number) {
  if (number &amp;gt; 0) {
    result = 'positive';
  } else {
    result = 'NOT positive';
  }
  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Bad&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function testNum(number) {
if (number &amp;gt; 0) {
  result = 'positive';
  } 
  else {
    result = 'NOT positive';
  }
  return result;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;One last argument&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is a final argument to clean your code if you are not completely convinced, There is an interesting quote from Martin Fowler&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”&lt;/em&gt;&lt;/strong&gt; — &lt;strong&gt;&lt;em&gt;Martin Fowler&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;




&lt;p&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of claps! 👏&lt;/p&gt;

&lt;p&gt;Please leave a comment with your feedback.&lt;/p&gt;

&lt;p&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev.to&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>programming</category>
      <category>development</category>
    </item>
    <item>
      <title>5 Simple UX Rules that make great front-end</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Mon, 07 Aug 2023 05:07:20 +0000</pubDate>
      <link>https://dev.to/rushitjivani/5-simple-ux-rules-that-make-great-front-end-3dgl</link>
      <guid>https://dev.to/rushitjivani/5-simple-ux-rules-that-make-great-front-end-3dgl</guid>
      <description>&lt;p&gt;You might agree that user experience (UX) is crucial for a website. But, did you know that web developers should also engage in UX design?&lt;/p&gt;

&lt;p&gt;This article will explain why web developers should include UX while developing the website and what it means for your end product.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a UX Designer?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;User experience designers create straightforward, understandable user interfaces that address customer problems in engaging and aesthetically beautiful ways.&lt;/p&gt;

&lt;p&gt;Designers need to be aware of users’ needs, attitudes, motivations, expectations, and pain points to produce a great experience.&lt;/p&gt;

&lt;p&gt;A UX designer does not always need prior design experience but should be able to think critically about how people interact with products.&lt;/p&gt;

&lt;p&gt;Now, let’s focus on how we can deliver an amazing user experience (UX)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Build better Interfaces&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Front-end development best practices focus on creating interfaces that pay close attention to every small detail of the provided designs. This includes incorporating the layouts, colors, typography, and spacing with precision and care.&lt;/p&gt;

&lt;p&gt;You can read &lt;a href="https://dev.to/rushitjivani/5-simple-ui-rules-that-make-great-front-end-572b"&gt;this article&lt;/a&gt; to enhance your UI skills.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fualfkn42680fijff25fx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fualfkn42680fijff25fx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Make Easy User Interaction&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Another great tip for creating a user-friendly UI is to make sure that user interaction is easy. The ultimate goal of UI design is to make it incredibly easy and efficient for users to accomplish their tasks and find what they’re looking for.&lt;/p&gt;

&lt;p&gt;For example, Use simple language that is easy to understand and avoid using industry and system-oriented language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsehg0befnqr4bp1kvvip.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsehg0befnqr4bp1kvvip.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Design for Short Attention Span&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Attention span is about how long a user concentrates on a given task without being distracted.&lt;/p&gt;

&lt;p&gt;A study conducted by Microsoft revealed that the average human attention span has decreased from &lt;a href="https://time.com/3858309/attention-spans-goldfish/" rel="noopener noreferrer"&gt;15 seconds to 8 seconds&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3umgxlx74aifp9fj518n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3umgxlx74aifp9fj518n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The solution is Simplify the interface by removing unnecessary elements or content that is not necessary to accomplish the user task.&lt;/p&gt;

&lt;p&gt;Commonly performed actions should be presented as large buttons, conveniently located within easy reach. Another approach to reducing unnecessary steps is to streamline the process and provide clear guidance, especially in places such as navigation, forms, and drop-downs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Cut out the clutter&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A simple and clean UI is super important for apps!&lt;/p&gt;

&lt;p&gt;It’s quite common to end up with a lot of elements on a small mobile screen. Sadly, this can create a cluttered experience that overwhelms the user, reduce their retention, and leads to disengagement.&lt;/p&gt;

&lt;p&gt;To prevent this, it helps to focus on only &lt;strong&gt;one thing&lt;/strong&gt; on every app screen as much as possible.&lt;/p&gt;

&lt;p&gt;One helpful approach is to divide your UI into multiple screens, each focusing on a specific topic or feature. This way, users can give their undivided attention to each screen and fully engage with the content.&lt;/p&gt;

&lt;p&gt;Here’s an example from Duolingo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyyr5trdhyzbr59bzsgfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyyr5trdhyzbr59bzsgfr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’ve used Duolingo before, you know they have a pretty extensive onboarding sequence. But you hardly get overwhelmed because they space everything nicely into multiple screens.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Intuitive design&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to Google, intuitive design refers to making products easy to use. When something resembles a button, for instance, we know that clicking on it will cause a certain action to occur. In the same way, if there is a link, we know that clicking it will either open a new web page or lead us to a different website.&lt;/p&gt;

&lt;p&gt;For instance, the majority of users are already aware that the hamburger icon, a three-line graphic, denotes a hidden menu.&lt;/p&gt;

&lt;p&gt;Users will find it easier to use that in your software than to develop a unique way of displaying a collapsible menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbawc7ax1f8odrlbu4c1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbawc7ax1f8odrlbu4c1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I hope it's clear by now how UX is the heart of any website’s front end. But everything needs practice and patience. With these five steps, you can better plan your transition.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of reaction! 🦄&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please leave a comment with your feedback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you’d like to support me as a writer, consider Following me on Dev, and Connecting with me on LinkedIn.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ux</category>
      <category>ui</category>
      <category>productivity</category>
    </item>
    <item>
      <title>5 Simple UI rules that make great front-end</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Wed, 02 Aug 2023 05:35:31 +0000</pubDate>
      <link>https://dev.to/rushitjivani/5-simple-ui-rules-that-make-great-front-end-572b</link>
      <guid>https://dev.to/rushitjivani/5-simple-ui-rules-that-make-great-front-end-572b</guid>
      <description>&lt;p&gt;UI development is an interesting topic that can sometimes be a bit unclear. We all know that UI stands for User Interface, so a UI Developer is someone who focuses on designing and developing the user interface. It may sound straightforward, but, the responsibilities of a UI Developer encompass much more than meets the eye.&lt;/p&gt;

&lt;p&gt;In this article, we’ll explore 5 wonderful tips that are widely recognized as excellent design practices.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Consistency &amp;amp; Alignment&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt; means keeping a consistent appearance across your interface. This includes using the same colors, fonts, and design elements. For instance, when you use the same button style and color throughout your application, it ensures a seamless and predictable user experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9waCJ5Jt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9ipiwtvu75dz1zpvz9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9waCJ5Jt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9ipiwtvu75dz1zpvz9v.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alignment refers to the placement of elements relative to each other or a common baseline, creating a sense of order and visual harmony. For example, vertically aligning form labels and input fields makes the form appear organized and easy to read.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J7aR1ZZM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zftn1x7gyrg45hftw8ky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J7aR1ZZM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zftn1x7gyrg45hftw8ky.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Constraining Whitespace Content&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is an incredibly easy method for anyone, Just ensure that your elements are perfectly aligned, down to the smallest detail, and that the spacing around each element is consistent and balanced.&lt;/p&gt;

&lt;p&gt;Have in mind that white space works as an invisible border. If you feel like you need a limit to separate two sections, maybe all you need is white space!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BhQDWTu2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smal4exku8nbjatv1zt4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BhQDWTu2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smal4exku8nbjatv1zt4.png" alt="Image description" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Color palettes and theory&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.toptal.com/designers/ui/ui-color-guide"&gt;Color theory&lt;/a&gt;&lt;/strong&gt; is the study of how colors interact and influence one another and the emotions and perceptions they evoke. In UI design, color helps guide users’ attention, convey information, and create a cohesive visual experience.&lt;/p&gt;

&lt;p&gt;In UI design, it’s important to pay attention to Color &amp;amp; Contrast because, without them, even websites with the best UI can end up looking unappealing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KX5lEhQz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o96fjhq2pr145eh6yoqw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KX5lEhQz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o96fjhq2pr145eh6yoqw.png" alt="Image description" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maintain a healthy text/color relationship by following these simple guidelines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always avoid low contrast between text and background.&lt;/li&gt;
&lt;li&gt;Don’t use complementary colors for text and background, especially when the colors are of similar brightness and saturation (e.g., yellow text on a purple background).&lt;/li&gt;
&lt;li&gt;Even on white backgrounds, don’t set body text in bright colors. Black and dark gray are the easiest to read.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Typography&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Typography&lt;/strong&gt; is an important part of UI design. It’s all about choosing and arranging fonts, sizes, and spacing to make the interface look good and be easy to read.&lt;/p&gt;

&lt;p&gt;For frontend developers, knowing about typography means thinking about things like which font to use, how to organize the text, and making sure it’s easy to read. This way, the text will look nice, convey the information well, and help create a good user experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PgtzlUqY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1eya8ecm430a3e96u5wo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PgtzlUqY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1eya8ecm430a3e96u5wo.png" alt="Image description" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Visual hierarchy&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Hierarchy&lt;/strong&gt; refers to the arrangement of design elements in order of importance, guiding the user’s attention through the interface. For example, using larger fonts for headings and smaller fonts for body text helps users easily distinguish between different sections.&lt;/p&gt;

&lt;p&gt;For example, Contrast helps establish a visual hierarchy, making it easy for users to understand the relative importance of different elements on the screen. For example, Your Call To Action button stand out by picking a color, style, and text that make it look different from the other things on the page. Where you put that button is also really important. Check out &lt;a href="https://www.zoho.com/academy/website-building/cta-buttons/best-practices-for-cta-placement.html"&gt;this post&lt;/a&gt; to find out the best ways to position your CTA.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lXF3MWm7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/867eg6vau3slnu3c72ez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lXF3MWm7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/867eg6vau3slnu3c72ez.png" alt="Image description" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this article, we discussed some UI ideas that can assist you in creating a more appealing UI. and as I mentioned before, UI is more than what meets the eye.&lt;/p&gt;

&lt;p&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of reaction! 🦄&lt;/p&gt;

&lt;p&gt;Please leave a comment with your feedback.&lt;/p&gt;

&lt;p&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ui</category>
      <category>ux</category>
      <category>webdesign</category>
    </item>
    <item>
      <title>React Native: Ultimate Guide to Create a Home Screen Widget for iOS and Android</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Thu, 27 Jul 2023 07:01:56 +0000</pubDate>
      <link>https://dev.to/rushitjivani/react-native-ultimate-guide-to-create-a-home-screen-widget-for-ios-and-android-1h9g</link>
      <guid>https://dev.to/rushitjivani/react-native-ultimate-guide-to-create-a-home-screen-widget-for-ios-and-android-1h9g</guid>
      <description>&lt;p&gt;Widgets are awesome tools that make your home screen look more attractive and also provide you with quick and useful information. In this post, we’ll show you how to create widgets for both Android and iOS and how to incorporate them into your React Native app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does the widget work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Widget works as an extension of your app. It cannot work as a standalone app itself. Widgets are available in three sizes (Small, Medium, and Large) and could be static or configurable. A widget is limited in terms of interaction. It cannot be scrollable, only tappable. A small widget can only have one type of interaction area whereas a medium and large widget can have multiple tappable areas of interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should you develop a widget?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Widgets are commonly created not only to keep users informed with important information and provide access to their applications from their home screen but also to differentiate those applications from competitors and maintain user engagement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Widgets with React Native&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;⚠️ Unfortunately, it is not possible to create a home screen widget using React Native. But don’t worry, we have a solution for you! In this guide, we’ll explore how to use a native widget to communicate with your React Native application. Let’s get started!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you prefer 🍖 rather than 📖, you can play with samples in &lt;a href="https://github.com/Rushit013/RNWidget.git" rel="noopener noreferrer"&gt;this repository&lt;/a&gt;. Pull requests, and other types of contributions are welcome!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🛠️ &lt;strong&gt;Setup&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Create a new app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;react-native init RNWidget
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Add a dependency that will be creating the bridge between the widget and the app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add react-native-shared-group-preferences
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; For communication with the native module add this code to your App.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {useState} from 'react';
import {
  View,
  TextInput,
  StyleSheet,
  NativeModules,
  SafeAreaView,
  Text,
  Image,
  ScrollView,
  KeyboardAvoidingView,
  Platform,
  ToastAndroid,
} from 'react-native';
import SharedGroupPreferences from 'react-native-shared-group-preferences';
import AwesomeButton from 'react-native-really-awesome-button';
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view';

const group = 'group.streak';

const SharedStorage = NativeModules.SharedStorage;

const App = () =&amp;gt; {
  const [text, setText] = useState('');
  const widgetData = {
    text,
  };

  const handleSubmit = async () =&amp;gt; {
    try {
      // iOS
      await SharedGroupPreferences.setItem('widgetKey', widgetData, group);
    } catch (error) {
      console.log({error});
    }
    const value = `${text} days`;
    // Android
    SharedStorage.set(JSON.stringify({text: value}));
    ToastAndroid.show('Change value successfully!', ToastAndroid.SHORT);
  };

  return (
    &amp;lt;SafeAreaView style={styles.safeAreaContainer}&amp;gt;
      &amp;lt;KeyboardAwareScrollView
        enableOnAndroid
        extraScrollHeight={100}
        keyboardShouldPersistTaps="handled"&amp;gt;
        &amp;lt;View style={styles.container}&amp;gt;
          &amp;lt;Text style={styles.heading}&amp;gt;Change Widget Value&amp;lt;/Text&amp;gt;
          &amp;lt;View style={styles.bodyContainer}&amp;gt;
            &amp;lt;View style={styles.instructionContainer}&amp;gt;
              &amp;lt;View style={styles.thoughtContainer}&amp;gt;
                &amp;lt;Text style={styles.thoughtTitle}&amp;gt;
                  Enter the value that you want to display on your home widget
                &amp;lt;/Text&amp;gt;
              &amp;lt;/View&amp;gt;
              &amp;lt;View style={styles.thoughtPointer}&amp;gt;&amp;lt;/View&amp;gt;
              &amp;lt;Image
                source={require('./assets/bea.png')}
                style={styles.avatarImg}
              /&amp;gt;
            &amp;lt;/View&amp;gt;

            &amp;lt;TextInput
              style={styles.input}
              onChangeText={newText =&amp;gt; setText(newText)}
              value={text}
              keyboardType="decimal-pad"
              placeholder="Enter the text to display..."
            /&amp;gt;

            &amp;lt;AwesomeButton
              backgroundColor={'#33b8f6'}
              height={50}
              width={'100%'}
              backgroundDarker={'#eeefef'}
              backgroundShadow={'#f1f1f0'}
              style={styles.actionButton}
              onPress={handleSubmit}&amp;gt;
              Submit
            &amp;lt;/AwesomeButton&amp;gt;
          &amp;lt;/View&amp;gt;
        &amp;lt;/View&amp;gt;
      &amp;lt;/KeyboardAwareScrollView&amp;gt;
    &amp;lt;/SafeAreaView&amp;gt;
  );
};

export default App;

const styles = StyleSheet.create({
  safeAreaContainer: {
    flex: 1,
    width: '100%',
    backgroundColor: '#fafaf3',
  },
  container: {
    flex: 1,
    width: '100%',
    padding: 12,
  },
  heading: {
    fontSize: 24,
    color: '#979995',
    textAlign: 'center',
  },
  input: {
    width: '100%',
    // fontSize: 20,
    minHeight: 50,
    borderWidth: 1,
    borderColor: '#c6c6c6',
    borderRadius: 8,
    padding: 12,
  },
  bodyContainer: {
    flex: 1,
    margin: 18,
  },
  instructionContainer: {
    margin: 25,
    paddingHorizontal: 20,
    paddingTop: 30,
    borderWidth: 1,
    borderRadius: 12,
    backgroundColor: '#ecedeb',
    borderColor: '#bebfbd',
    marginBottom: 35,
  },
  avatarImg: {
    height: 180,
    width: 180,
    resizeMode: 'contain',
    alignSelf: 'flex-end',
  },
  thoughtContainer: {
    minHeight: 50,
    borderRadius: 12,
    borderWidth: 1,
    padding: 12,
    backgroundColor: '#ffffff',
    borderColor: '#c6c6c6',
  },
  thoughtPointer: {
    width: 0,
    height: 0,
    borderStyle: 'solid',
    overflow: 'hidden',
    borderTopWidth: 12,
    borderRightWidth: 10,
    borderBottomWidth: 0,
    borderLeftWidth: 10,
    borderTopColor: 'blue',
    borderRightColor: 'transparent',
    borderBottomColor: 'transparent',
    borderLeftColor: 'transparent',
    marginTop: -1,
    marginLeft: '50%',
  },
  thoughtTitle: {
    fontSize: 14,
  },
  actionButton: {
    marginTop: 40,
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let me explain how to use SharedGroupPreferences and SharedStorage in your app. SharedGroupPreferences is imported from the library and you can use it by storing an item with the setItem method, using a key, value, and group. For this example, the key will be widgetKey, the value will be widgetData, a JavaScript object that contains user input, and the group will be the name of the group that will share the information between the app and the widget. We will talk more about this when we get to the Swift code.&lt;/p&gt;

&lt;p&gt;Now, for Android, we’ll use SharedStorage. You don’t need to install any additional libraries for this, since it’s included in the React Native package. The value will be a serialized JavaScript object, which will be converted to a string and saved using the set SharedStorage method. Easy peasy, right?&lt;/p&gt;

&lt;p&gt;For native code. Let’s start with iOS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🍏 &lt;strong&gt;Implementation for iOS&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Open your app project in Xcode and choose File &amp;gt; New &amp;gt; Target.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F554bywqkz9agcmvgcdaj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F554bywqkz9agcmvgcdaj.png" alt="Image description" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; From the Application Extension group, select Widget Extension, and then click Next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq62lo3pshk4l7s1kho4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjq62lo3pshk4l7s1kho4.png" alt="Image description" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Enter the name of your extension.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F689b1khmbgvf7di2iocr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F689b1khmbgvf7di2iocr.png" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; If the widget provides user-configurable properties, check the Include Configuration Intent checkbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi4u5h9mwiqqxe06h7gu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi4u5h9mwiqqxe06h7gu0.png" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; Click Finish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.&lt;/strong&gt; If it asks to activate the scheme, click Activate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fialx35umc95b6ppdirfi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fialx35umc95b6ppdirfi.png" alt="Image description" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7.&lt;/strong&gt; Your widget is ready to go! You now have a new folder that contains all the essential files for your widget.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1lcvt767dj2baj0he8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1lcvt767dj2baj0he8c.png" alt="Image description" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8.&lt;/strong&gt; Before we move on to the next step, let’s test out your basic widget. To do this, simply open up your terminal and run the app using the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;react-native run-ios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9.&lt;/strong&gt; To add a widget you have to tap and hold the home screen until a ➕ appears in the upper left corner. When you click on the icon, a list of apps will appear. Our newly created app should be included.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59q9frjdjdzz517tn0r6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59q9frjdjdzz517tn0r6.png" alt="Image description" width="388" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10.&lt;/strong&gt; To communicate with React Native widget we have to add “App Group”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ky8lew3so9w2jj2h37m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ky8lew3so9w2jj2h37m.png" alt="Image description" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11.&lt;/strong&gt; Now for our Streak widget edit StreakWidget.swift with the below code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import WidgetKit
import SwiftUI
import Intents

struct WidgetData: Decodable {
   var text: String
}

struct Provider: IntentTimelineProvider {
   func placeholder(in context: Context) -&amp;gt; SimpleEntry {
      SimpleEntry(date: Date(), configuration: ConfigurationIntent(), text: "Placeholder")
  }

  func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -&amp;gt; ()) {
      let entry = SimpleEntry(date: Date(), configuration: configuration, text: "Data goes here")
      completion(entry)
  }

   func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline&amp;lt;SimpleEntry&amp;gt;) -&amp;gt; Void) {
      let userDefaults = UserDefaults.init(suiteName: "group.streak")
      if userDefaults != nil {
        let entryDate = Date()
        if let savedData = userDefaults!.value(forKey: "widgetKey") as? String {
            let decoder = JSONDecoder()
            let data = savedData.data(using: .utf8)
            if let parsedData = try? decoder.decode(WidgetData.self, from: data!) {
                let nextRefresh = Calendar.current.date(byAdding: .minute, value: 5, to: entryDate)!
                let entry = SimpleEntry(date: nextRefresh, configuration: configuration, text: parsedData.text)
                let timeline = Timeline(entries: [entry], policy: .atEnd)
                completion(timeline)
            } else {
                print("Could not parse data")
            }
        } else {
            let nextRefresh = Calendar.current.date(byAdding: .minute, value: 5, to: entryDate)!
            let entry = SimpleEntry(date: nextRefresh, configuration: configuration, text: "No data set")
            let timeline = Timeline(entries: [entry], policy: .atEnd)
            completion(timeline)
        }
      }
  }
}

struct SimpleEntry: TimelineEntry {
   let date: Date
      let configuration: ConfigurationIntent
      let text: String
}

struct StreakWidgetEntryView : View {
  var entry: Provider.Entry

  var body: some View {
    HStack {
      VStack(alignment: .leading, spacing: 0) {
        HStack(alignment: .center) {
          Image("streak")
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: 37, height: 37)
          Text(entry.text)
            .foregroundColor(Color(red: 1.00, green: 0.59, blue: 0.00))
            .font(Font.system(size: 21, weight: .bold, design: .rounded))
            .padding(.leading, -8.0)
        }
        .padding(.top, 10.0)
        .frame(maxWidth: .infinity)
        Text("Way to go!")
          .foregroundColor(Color(red: 0.69, green: 0.69, blue: 0.69))
          .font(Font.system(size: 14))
          .frame(maxWidth: .infinity)
        Image("duo")
          .renderingMode(.original)
          .resizable()
          .aspectRatio(contentMode: .fit)
          .frame(maxWidth: .infinity)

      }
    }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
  }
}

@main
struct StreakWidget: Widget {
  let kind: String = "StreakWidget"

  var body: some WidgetConfiguration {
    IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
      StreakWidgetEntryView(entry: entry)
    }
    .configurationDisplayName("My Widget")
    .description("This is an example widget.")
  }
}

struct StreakWidget_Previews: PreviewProvider {
  static var previews: some View {
    StreakWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent(), text: "Widget preview"))
      .previewContext(WidgetPreviewContext(family: .systemSmall))
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Basically:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read the UserDefaults object from the shared group we created before
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let userDefaults = UserDefaults.init(suiteName: "group.streak")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Get the data (which has been encoded in string form)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let savedData = userDefaults!.value(forKey: "widgetKey")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Decode into an object
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let parsedData = try? decoder.decode(WidgetData.self, from: data!)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a timeline of said objects
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nextRefresh = Calendar.current.date(byAdding: .minute, value: 5, to: entryDate)!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that the objects added to the Timeline struct must comply with the TimelineEntry protocol, which means they need to have a Date field and nothing else. This is important information to keep in mind.&lt;/p&gt;

&lt;p&gt;That’s all there is to it for iOS. Simply run npm start and test your app on either a virtual or real device.&lt;/p&gt;

&lt;p&gt;After you’ve installed the app, all you need to do is select the widget from the widget list and put it on your home screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgq6v90bxzaujcvmfvov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgq6v90bxzaujcvmfvov.png" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, open the app and type something in the input field, press enter, and go back to the home screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqwgfmw2ki117f0pxzok.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxqwgfmw2ki117f0pxzok.png" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that’s it for iOS, Now, let’s explore how we can accomplish the same thing on Android.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🤖 &lt;strong&gt;Implementation for Android&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Open the Android folder on Android Studio. Then, inside Android Studio, right-click on res &amp;gt; New &amp;gt; Widget &amp;gt; App Widget:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdhubqqvzu2co3vkrxy0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdhubqqvzu2co3vkrxy0.png" alt="Image description" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Name and configure your widget, and click Finish:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ync3y53yqiukkx1xdvy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ync3y53yqiukkx1xdvy.png" alt="Image description" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Now run the app and you can see the widget available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.&lt;/strong&gt; To communicate between the widget and the React Native app we’ll be using the SharedPreferences Android native module, which is just like UserDefaults for iOS.&lt;/p&gt;

&lt;p&gt;This involves adding new &lt;code&gt;SharedStorage.java&lt;/code&gt; and &lt;code&gt;SharedStoragePackager.java&lt;/code&gt; files to the same directory as your MainApplication.java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SharedStorage.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.rnwidget;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;

public class SharedStorage extends ReactContextBaseJavaModule {
 ReactApplicationContext context;

 public SharedStorage(ReactApplicationContext reactContext) {
  super(reactContext);
  context = reactContext;
 }

 @Override
 public String getName() {
  return "SharedStorage";
 }

 @ReactMethod
 public void set(String message) {
  SharedPreferences.Editor editor = context.getSharedPreferences("DATA", Context.MODE_PRIVATE).edit();
  editor.putString("appData", message);
  editor.commit();

  Intent intent = new Intent(getCurrentActivity().getApplicationContext(), StreakWidget.class);
  intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  int[] ids = AppWidgetManager.getInstance(getCurrentActivity().getApplicationContext()).getAppWidgetIds(new ComponentName(getCurrentActivity().getApplicationContext(), StreakWidget.class));
  intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
  getCurrentActivity().getApplicationContext().sendBroadcast(intent);

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SharedStoragePackager.java&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.rnwidget;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SharedStoragePackager implements ReactPackage {

 @Override
 public List&amp;lt;ViewManager&amp;gt; createViewManagers(ReactApplicationContext reactContext) {
  return Collections.emptyList();
 }

 @Override
 public List&amp;lt;NativeModule&amp;gt; createNativeModules(ReactApplicationContext reactContext) {
  List&amp;lt;NativeModule&amp;gt; modules = new ArrayList&amp;lt;&amp;gt;();

  modules.add(new SharedStorage(reactContext));

  return modules;
 }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5.&lt;/strong&gt; Change the package name for your app as shown in AndroidManifest.xml file inside android &amp;gt; app &amp;gt; src &amp;gt; main.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjn4pag216fl9ak2f2ug4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjn4pag216fl9ak2f2ug4.png" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.&lt;/strong&gt; After placing those necessary adjustments, go ahead and add this code to your MainApplication.java file within the getPackages method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;packages.add(new SharedStoragePackager());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7.&lt;/strong&gt; With the bridge set up, let’s move on to receiving data in StreakWidget.java. To update the widget’s content, we’ll need to use SharedPreferences and manage it with the updateAppWidget method. Here’s the code to replace your existing one with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.rnwidget;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.widget.RemoteViews;
import android.content.SharedPreferences;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Implementation of App Widget functionality.
 */
public class StreakWidget extends AppWidgetProvider {

    static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                                int appWidgetId) {

        try {
            SharedPreferences sharedPref = context.getSharedPreferences("DATA", Context.MODE_PRIVATE);
            String appString = sharedPref.getString("appData", "{\"text\":'no data'}");
            JSONObject appData = new JSONObject(appString);
            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.streak_widget);
            views.setTextViewText(R.id.appwidget_text, appData.getString("text"));
            appWidgetManager.updateAppWidget(appWidgetId, views);
        }catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        // There may be multiple widgets active, so update all of them
        for (int appWidgetId : appWidgetIds) {
            updateAppWidget(context, appWidgetManager, appWidgetId);
        }
    }

    @Override
    public void onEnabled(Context context) {
        // Enter relevant functionality for when the first widget is created
    }

    @Override
    public void onDisabled(Context context) {
        // Enter relevant functionality for when the last widget is disabled
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8.&lt;/strong&gt; Now, let’s talk about the widget’s appearance. This step is optional, but we’ll use the same design as in the iOS example. In Android Studio, navigate to your app &amp;gt; res &amp;gt; layout &amp;gt; streak_widget.xml file. And you can check out the design preview like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi3n98yzxwu8uvs1m4pce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi3n98yzxwu8uvs1m4pce.png" alt="Image description" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9.&lt;/strong&gt; That’s all there is to it! Give it a test run on an Android device&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa0eyvy6npf2ym27ylat6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa0eyvy6npf2ym27ylat6.gif" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Great job! By learning how to create the AppWidget with React Native, you’ve added a valuable skill to your toolkit. Even if this topic is new to you, don’t worry — it’s straightforward and easy to use in your applications. Keep up the good work!&lt;/p&gt;

&lt;p&gt;Kindly give it a clap 👏🏻 and share it with your friends!&lt;/p&gt;

&lt;p&gt;Please leave a comment with your feedback.&lt;/p&gt;

&lt;p&gt;If you’d like to support me as a writer, consider Following me on &lt;a href="https://dev.to/rushitjivani"&gt;Dev&lt;/a&gt;, and Connecting with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Dynamically change app launcher icon in React Native</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Mon, 17 Jul 2023 05:01:32 +0000</pubDate>
      <link>https://dev.to/rushitjivani/dynamically-change-app-launcher-icon-in-react-native-f8j</link>
      <guid>https://dev.to/rushitjivani/dynamically-change-app-launcher-icon-in-react-native-f8j</guid>
      <description>&lt;p&gt;Have you ever used Tinder? if yes then can notice their app icon has a &lt;strong&gt;pink base color&lt;/strong&gt;, but when a user upgrades to the &lt;strong&gt;gold membership&lt;/strong&gt;, the &lt;strong&gt;icon changes&lt;/strong&gt; to reflect that subscription level without requiring a new app download.&lt;/p&gt;

&lt;p&gt;Today we’ll be exploring a cool npm package called &lt;code&gt;react-native-change-icon&lt;/code&gt; that allows us to effortlessly switch up our app icon. Exciting, right? Let’s dive in and see how we can use it!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🛠️ &lt;strong&gt;Installation&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To get started, let’s open up your CLI and head over to your project directory. Once you’re there, go ahead and run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i react-native-change-icon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add react-native-change-icon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;🤖 &lt;strong&gt;Implementation for Android&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that you have your app icons, let’s head to the &lt;strong&gt;“android”&lt;/strong&gt; directory of your project, followed by &lt;code&gt;android -&amp;gt;app -&amp;gt; src -&amp;gt; main -&amp;gt; res -&amp;gt; mipmap-*&lt;/code&gt; directories, and add all the icons you require.&lt;/p&gt;

&lt;p&gt;When you’re finished adding the icons, take a look at your folder; it should appear something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pXEozc1I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnir8af2or169pvktans.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pXEozc1I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnir8af2or169pvktans.png" alt="Image description" width="234" height="826"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To update your AndroidManifest.xml file, simply add an activity-alias for each of your app icons like this!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;activity-alias
     android:name="com.rndynamicicon.MainActivitylogo_1"
     android:enabled="false"
     android:exported="true"
     android:icon="@mipmap/logo_1"
     android:targetActivity=".MainActivity"&amp;gt;
     &amp;lt;intent-filter&amp;gt;
       &amp;lt;action android:name="android.intent.action.MAIN" /&amp;gt;
       &amp;lt;category android:name="android.intent.category.LAUNCHER" /&amp;gt;
     &amp;lt;/intent-filter&amp;gt;
&amp;lt;/activity-alias&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your package name and MainActivity name will be followed by the app icon name in this section. When you’re finished, your &lt;code&gt;AndroidManifest.xml&lt;/code&gt; file will have a similar appearance to this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"&amp;gt;

 &amp;lt;uses-permission android:name="android.permission.INTERNET" /&amp;gt;

 &amp;lt;application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/logored"
  android:allowBackup="false"
  android:theme="@style/AppTheme"&amp;gt;
  &amp;lt;activity
    android:name=".MainActivity" /&amp;gt;
     &amp;lt;activity-alias
         android:name="com.rndynamicicon.MainActivitylogo_1"
         android:enabled="false"
         android:exported="true"
         android:icon="@mipmap/logo_1"
         android:targetActivity=".MainActivity"&amp;gt;
         &amp;lt;intent-filter&amp;gt;
           &amp;lt;action android:name="android.intent.action.MAIN" /&amp;gt;
           &amp;lt;category android:name="android.intent.category.LAUNCHER" /&amp;gt;
         &amp;lt;/intent-filter&amp;gt;
    &amp;lt;/activity-alias&amp;gt;
    &amp;lt;activity-alias
       android:name="com.rndynamicicon.MainActivitylogo_2"
       android:enabled="false"
       android:exported="true"
       android:icon="@mipmap/logo_2"
       android:targetActivity=".MainActivity"&amp;gt;
       &amp;lt;intent-filter&amp;gt;
         &amp;lt;action android:name="android.intent.action.MAIN" /&amp;gt;
         &amp;lt;category android:name="android.intent.category.LAUNCHER" /&amp;gt;
       &amp;lt;/intent-filter&amp;gt;
    &amp;lt;/activity-alias&amp;gt;
 &amp;lt;/application&amp;gt;
&amp;lt;/manifest&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have the flexibility to create even more alternate icons by simply adding more  tags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If you are using any deep links inside the app, then please put them in all the activity alias.&lt;/li&gt;
&lt;li&gt;Only one activity alias should be enabled initially, otherwise, it will create multiple launcher icon at the time time of app launching.&lt;/li&gt;
&lt;li&gt;Should enable the default activity alias which we want to show on the first time of app launching.&lt;/li&gt;
&lt;li&gt;If you want a different name with each launcher icon then you can also change the label name in each activity alias.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;🍏 &lt;strong&gt;Implementation for iOS&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;First, go to the &lt;code&gt;ios/&lt;/code&gt; folder and do &lt;code&gt;pod install&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Open your app in Xcode and add an &lt;code&gt;AppIcons&lt;/code&gt; group to your app.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QWwKjVQ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii8h2cp76lqraap7z079.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QWwKjVQ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ii8h2cp76lqraap7z079.png" alt="Image description" width="800" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add all your images as &lt;code&gt;image@2x.png&lt;/code&gt; and &lt;code&gt;image@3x.png&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OF3r9dBe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwlv03c3irp1r1zeivus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OF3r9dBe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwlv03c3irp1r1zeivus.png" alt="Image description" width="800" height="606"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open the &lt;code&gt;Info.plist&lt;/code&gt; file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add &lt;code&gt;Icon files (iOS 5)&lt;/code&gt; to the Information Property List.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xEcD4WAt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ph37qay8fs58klx84mys.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xEcD4WAt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ph37qay8fs58klx84mys.png" alt="Image description" width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add &lt;code&gt;CFBundleAlternateIcons&lt;/code&gt; as a dictionary to the Icon files (iOS 5) as it is used for the alternative icons.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6v__7gLD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7ivb01ipfjcta5nu4eg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6v__7gLD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7ivb01ipfjcta5nu4eg.png" alt="Image description" width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add dictionaries under &lt;code&gt;CFBundleAlternateIcons&lt;/code&gt; named as your icon names in the &lt;code&gt;AppIcons&lt;/code&gt; group.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AYGWWMwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4r3jfkd5yydf6rl1jwf7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AYGWWMwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4r3jfkd5yydf6rl1jwf7.png" alt="Image description" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For each dictionary, these two properties &lt;code&gt;UIPrerenderedIcon&lt;/code&gt; and &lt;code&gt;CFBundleIconFiles&lt;/code&gt; need to be configured.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LJ1ZxlfV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xoj1uvczmekk6qdvvnik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LJ1ZxlfV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xoj1uvczmekk6qdvvnik.png" alt="Image description" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Set the type of &lt;code&gt;UIPrerenderedIcon&lt;/code&gt; to &lt;code&gt;String&lt;/code&gt; and its value to &lt;code&gt;NO&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set the &lt;code&gt;type&lt;/code&gt; of &lt;code&gt;CFBundleIconFiles&lt;/code&gt; to Array &lt;code&gt;and set its first key&lt;/code&gt; ,Item 0 &lt;code&gt;to&lt;/code&gt; String with the value of the icon name.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VsIXFE_9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17fg2jbcphgb7iciqmvj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VsIXFE_9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17fg2jbcphgb7iciqmvj.png" alt="Image description" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;set the default icon name in &lt;code&gt;Primary Icon&lt;/code&gt; and &lt;code&gt;Newsstand Icon&lt;/code&gt; -&amp;gt; &lt;code&gt;Icon files&lt;/code&gt; -&amp;gt; &lt;code&gt;Item 0&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3ywXAoIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sspubzceyozfruofbyxq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3ywXAoIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sspubzceyozfruofbyxq.png" alt="Image description" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;👨‍💻 &lt;strong&gt;JS side&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After these steps, we have the ability to change the icon in the JS code of our application. Let’s import the library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { changeIcon, getIcon } from 'react-native-change-icon';

changeIcon('iconname');        // pass the icon name to change the icon 

getIcon();                     // to get the currently active icon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well, that’s it. 🎉 Run the code to see it in action.🥳&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qXh3937J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zn584odw7gnnf48sp74.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qXh3937J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zn584odw7gnnf48sp74.gif" alt="Image description" width="600" height="1298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please check out the &lt;a href="https://github.com/Rushit013/RNDynamicIcon"&gt;demo project&lt;/a&gt; on GitHub for more information&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of reaction! 🦄&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy Coding :)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>An Ultimate all-in-one Auth Module in React Native: Enable One-line Sign-Up and Sign in with Eartho on your device.</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Tue, 11 Jul 2023 07:22:37 +0000</pubDate>
      <link>https://dev.to/rushitjivani/an-ultimate-all-in-one-auth-module-in-react-native-enable-one-line-sign-up-and-sign-in-with-eartho-on-your-device-17a1</link>
      <guid>https://dev.to/rushitjivani/an-ultimate-all-in-one-auth-module-in-react-native-enable-one-line-sign-up-and-sign-in-with-eartho-on-your-device-17a1</guid>
      <description>&lt;p&gt;One of the first features you must develop when building an app is a simple and seamless login and sign up flow in which users don’t need to remember complicated passwords.&lt;/p&gt;

&lt;p&gt;A very interesting option for this is &lt;a href="https://www.eartho.world/"&gt;Eartho One&lt;/a&gt;. It’s one of the most famous platforms which provides the facilities of passwordless authentication and many more.&lt;/p&gt;

&lt;p&gt;In this article, we’re going to dive into building a super cool React Native application using Eartho for passwordless authentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you prefer 🍖 rather than 📖, you can play with samples in &lt;a href="https://github.com/Rushit013/RNEarthoAuth"&gt;this repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why passwordless authentication?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implementing passwordless authentication can be very helpful for both Developer and your customers! The best part about it is how easy it is to use. With passwordless authentication, your customers can quickly and easily log in without needing to remember a complicated code or go through the hassle of resetting their password if they forget it. Not only does this save your customers time and frustration, but it also saves you time and resources by eliminating the process of resetting passwords for customers who forget their email address, phone number, or login credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Eartho one?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ready high converting UI/UX&lt;/li&gt;
&lt;li&gt;Login from Google, Twitter, Github, Facebook, Apple, Microsoft, VK, Snapchat, Yandex, Reddit, SMS, Metamask at once with no extra steps or extra effort.&lt;/li&gt;
&lt;li&gt;Users will be protected under the third layer, which prevents companies to track after users.&lt;/li&gt;
&lt;li&gt;Set boundaries and rules to stop users you don’t want from connecting.&lt;/li&gt;
&lt;li&gt;Advanced analytics and info about your app from all sources. ready for use. no extra steps&lt;/li&gt;
&lt;li&gt;No-Code / Your own server. you decide.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Going Passwordless with React Native and Eartho one&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up for an account with &lt;a href="https://creator.eartho.world/"&gt;Eartho Creators&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wQmW_41r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54ucr69luxklou4lfg6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wQmW_41r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54ucr69luxklou4lfg6u.png" alt="Image description" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on &lt;strong&gt;“Add Project”&lt;/strong&gt; on the creators’ home screen to create your first project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LdRjcFu2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r6i7b2lrodbta653a3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LdRjcFu2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6r6i7b2lrodbta653a3g.png" alt="Image description" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once you have created the project, you can access the &lt;strong&gt;“Add Access”&lt;/strong&gt; option on the project page. From there, you can create the access points for your Eartho project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eysb0ssm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jtww9hiaj800g8ohi7b.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eysb0ssm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jtww9hiaj800g8ohi7b.gif" alt="Image description" width="600" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the SDK and initialize Eartho One with the below command
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @eartho/one-client-react-native
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;For iOS, add URL type
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Identifier: eartho

URL Schemes: $(PRODUCT_BUNDLE_IDENTIFIER).one.eartho.world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BGP3-2Si--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4kpbe7rzdf9e9uev1cb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BGP3-2Si--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4kpbe7rzdf9e9uev1cb.png" alt="Image description" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Integrating Eartho into your app
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { init as earthoInit, connectWithRedirect, getIdToken, getUser } from '@eartho/one-client-react-native';

//1. Init the sdk
React.useEffect(() =&amp;gt; {

earthoInit(
  "YOUR_EARTHO_CLIENT_ID", 
  "YOUR_EARTHO_CLIENT_SECRET");

}, []);


//2. open the access dialog
connectWithRedirect("access id: e.g. YOUR_EARTHO_ACCESS_ID")


//3. Get id token or user 

console.log(await getIdToken());
console.log(await getUser());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Copy your Eartho values from the &lt;strong&gt;“setup tab”&lt;/strong&gt; And replace them with &lt;code&gt;YOUR_EARTHO_CLIENT_ID&lt;/code&gt; , &lt;code&gt;YOUR_EARTHO_CLIENT_SECRET&lt;/code&gt;, &lt;code&gt;YOUR_EARTHO_ACCESS_ID&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kcZH9vV3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7i9pwh8ukx4s2vjcnupd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kcZH9vV3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7i9pwh8ukx4s2vjcnupd.png" alt="Image description" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--briHIcIm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpbsojd3g5tft2t7e77l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--briHIcIm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpbsojd3g5tft2t7e77l.png" alt="Image description" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Well, that’s it. 🎉 Run the code to see it in action.🥳&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--opBMEwdv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/amc5n8zyjvu8l3g4oyle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--opBMEwdv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/amc5n8zyjvu8l3g4oyle.png" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want to add Firebase as a back-end? then follow the below steps&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://console.cloud.google.com/iam-admin/serviceaccounts?authuser=0"&gt;https://console.cloud.google.com/iam-admin/serviceaccounts?authuser=0&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Watch this helpful video for more guidance: &lt;a href="https://youtu.be/wpbHI-4W33g"&gt;https://youtu.be/wpbHI-4W33g&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Save the JSON file&lt;/li&gt;
&lt;li&gt;Visit &lt;a href="https://creator.eartho.world/"&gt;https://creator.eartho.world/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select your entity and go to the security tab&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0MBRiNYd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c9ow3svtm2vnvdzbv5x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0MBRiNYd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c9ow3svtm2vnvdzbv5x.png" alt="Image description" width="800" height="820"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change the environment to Firebase Auth&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PMRtNm9j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzkq3vfpomtlybz7p973.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PMRtNm9j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzkq3vfpomtlybz7p973.png" alt="Image description" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finally, copy the content from the JSON file and paste it onto the website.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it! You done&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrapping Up&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Passwordless authentication can make the login process easier and more secure compared to traditional username and password authentication. However, setting up a passwordless authentication system from scratch can be difficult. Fortunately, Eartho simplifies the process by allowing us to easily create an app with passwordless authentication.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of reaction! 🦄&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please leave a comment with your feedback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Connect with me on &lt;a href="https://www.linkedin.com/in/rushit-jivani-a0a329194/"&gt;LinkedIn&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>firebase</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Introducing FlashList: The New and Improved Alternative to FlatList for React Native!</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Wed, 05 Jul 2023 04:35:29 +0000</pubDate>
      <link>https://dev.to/rushitjivani/introducing-flashlist-the-new-and-improved-alternative-to-flatlist-for-react-native-3olb</link>
      <guid>https://dev.to/rushitjivani/introducing-flashlist-the-new-and-improved-alternative-to-flatlist-for-react-native-3olb</guid>
      <description>&lt;p&gt;When it comes to rendering large lists in React Native, performance can become a bottleneck. Rendering a long list of items can cause delays and slow down the user interface, making the application feel sluggish and unresponsive.&lt;/p&gt;

&lt;p&gt;But look no further because here comes the rescue!&lt;/p&gt;

&lt;p&gt;Before we look into the solution, let’s discuss the problem!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you render large lists which have 500+ items, then I'm pretty sure you ran into this warning&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;VirtualizedList: You have a large list that is slow to update — make sure your renderItem function renders components that follow React performance best practices like PureComponent, shouldComponentUpdate, etc.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This usually happens when we add lots of items to a FlatList, and those items contain dynamic components with animations or other interactions, it can slow things down.&lt;/p&gt;

&lt;p&gt;The FlatList here simply says it can’t handle the list to render smoothly. Then you research on the internet and try to optimize the FlatList by using props like &lt;code&gt;removedClippedSubviews&lt;/code&gt;, &lt;code&gt;initialNumToRender&lt;/code&gt;, &lt;code&gt;maxToRenderPerBatch&lt;/code&gt;, &lt;code&gt;windowSize&lt;/code&gt;, &lt;code&gt;getItemLayout&lt;/code&gt; and many more.&lt;/p&gt;

&lt;p&gt;But it’s still not enough to make the list render smoothly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What about The existing solution RecyclerListView?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Flipkart/recyclerlistview"&gt;RecyclerListView&lt;/a&gt; is a third-party package optimized for rendering large amounts of data with very good real-world performance.&lt;/p&gt;

&lt;p&gt;RecyclerListView is JS only with no native dependencies, inspired by both &lt;code&gt;RecyclerView&lt;/code&gt; on Android and &lt;code&gt;UICollectionView&lt;/code&gt; on iOS. It is highly performant and is as feature-rich as the built-in &lt;code&gt;FlatList&lt;/code&gt; component.&lt;/p&gt;

&lt;p&gt;The flaws of &lt;code&gt;FlatList&lt;/code&gt; were taken into consideration when developing the &lt;code&gt;RecyclerListView&lt;/code&gt; package. &lt;code&gt;RecyclerListView&lt;/code&gt; cleverly recycles previously produced views rather than creating new views for onscreen components and destroying views for offscreen elements. This technique is known as “cell recycling“. And it allows views that are no longer visible to be used to render items.&lt;/p&gt;

&lt;p&gt;But as developers you must spend a lot of time understanding how it works, playing with it, and requiring significant amounts of code to manage. For example, RecyclerListView needs predicted size estimates for each item and if they aren’t accurate, the UI performance suffers. It also renders the entire layout in JavaScript, which can lead to visible glitches.&lt;/p&gt;

&lt;p&gt;RecyclerListView works very well! But it’s just too difficult to use most of the time. It’s even harder if you have items with dynamic heights that can’t be measured in advance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Meet FlashList! A speedy alternative to FlatList that works on the UI thread and according to their website, it runs 10 times faster on JS thread and 5 times faster on the UI thread.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y1mN1aln--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5j5pk9w4beyfriji6c5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y1mN1aln--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5j5pk9w4beyfriji6c5w.png" alt="Image description" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To get started with FlashList, simply install it by running this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @shopify/flash-list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you’ve installed FlashList, simply navigate to the ios directory and run &lt;code&gt;pod install&lt;/code&gt;. That’s it! Your setup is complete.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;FlatList&lt;/code&gt; and &lt;code&gt;FlashList&lt;/code&gt; seem similar and have similar syntax. That means you can use all the &lt;code&gt;FlatList&lt;/code&gt; props like &lt;code&gt;data&lt;/code&gt;, &lt;code&gt;renderItem&lt;/code&gt;, &lt;code&gt;ListEmptyScrollComponent&lt;/code&gt;, and so on. If you are familiar with the FlatList properties, there won't be many changes. The only difference is that it uses &lt;code&gt;RecyclerView&lt;/code&gt; instead of &lt;code&gt;VirtualizedList&lt;/code&gt; as the underlying component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How FlashList is the best solution for FlatList and RecyclerListView?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FlatList was not performant enough, but was easy to implement, and RecyclerListView was performant, but its API was difficult to understand. So, the idea was simple: can we combine the best of both, using the FlatList API, but gain RecyclerListView performance? and That’s how FlashList⚡️ was born.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uj2AC3p6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvx5q3mbedsd3cb10zn7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uj2AC3p6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvx5q3mbedsd3cb10zn7.png" alt="Image description" width="768" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;FlashList&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;FlashList
  data={DATA}
  renderItem={({ item }) =&amp;gt; &amp;lt;Text&amp;gt;{item.title}&amp;lt;/Text&amp;gt;}
  estimatedItemSize={200}
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do you see how simple that is?&lt;/p&gt;

&lt;p&gt;FlashList uses &lt;code&gt;estimatedItemSize&lt;/code&gt; to determine the number of items that should be displayed on the screen during the initial load and while scrolling.&lt;/p&gt;

&lt;p&gt;How does it achieve this? Rather than destroying the component when an item goes out of the viewport, &lt;code&gt;FlashList&lt;/code&gt; renders the same component with different item &lt;code&gt;properties&lt;/code&gt;. When using &lt;code&gt;FlashList&lt;/code&gt;, it’s important to avoid adding key &lt;code&gt;properties&lt;/code&gt; to the item component as recommended by &lt;code&gt;React&lt;/code&gt;. This will prevent views from being recycled, which would negate all the benefits of &lt;code&gt;FlatList&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/DhS_y_0oLzA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that’s that! Feel free to take a look at the library for yourself at &lt;a href="https://shopify.github.io/flash-list/"&gt;https://shopify.github.io/flash-list/&lt;/a&gt; and give it a try! You’ll see how easy it is to swap out your current FlatLists for FlashList, and you may notice some improved performance.&lt;/p&gt;

&lt;p&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of reaction! 🦄&lt;/p&gt;

&lt;p&gt;Happy Coding :)&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>tutorial</category>
      <category>performance</category>
      <category>programming</category>
    </item>
    <item>
      <title>Learn how to perform unit testing in React Native with Jest.</title>
      <dc:creator>Rushit Jivani</dc:creator>
      <pubDate>Mon, 26 Jun 2023 11:51:23 +0000</pubDate>
      <link>https://dev.to/rushitjivani/learn-how-to-perform-unit-testing-in-react-native-with-jest-od5</link>
      <guid>https://dev.to/rushitjivani/learn-how-to-perform-unit-testing-in-react-native-with-jest-od5</guid>
      <description>&lt;p&gt;Hey there! Have you ever found yourself in a situation where you solved one problem, but then ended up introducing a new bug weeks later without realizing it? Well, it happens to the best of us! But, the good news is that you can easily avoid this by writing tests for your app.&lt;/p&gt;

&lt;p&gt;When working on a project with a lot on your plate and tight deadlines, writing tests can often be overlooked and underestimated. However, once you learn how to write tests, you’ll see that it’s not as difficult as it may seem, and the benefits are well worth it! By writing tests, you can avoid future problems and make your life a lot easier in the long run.&lt;/p&gt;

&lt;p&gt;So, I was recently tasked with writing Unit test cases for one of my client projects, and I gotta say, I was feeling a bit lost. It seems like there aren’t a lot of great resources out there to help you understand the concepts properly. The information is scattered all over the place, and it’s tough to figure out the best way to get started with Unit testing in React Native.&lt;/p&gt;

&lt;p&gt;After a long search on the internet, I came across this quote&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“It’s hard enough to find an error in your code when you’re looking for it; it’s even harder when you’ve assumed your code is error-free.”&lt;/em&gt; — &lt;strong&gt;Steve McConnell&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we will focus on unit testing by providing a simple example of how to test a React Native app. This article is intended for anyone who is very new to testing in React Native.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Jest?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://jestjs.io/"&gt;Jest&lt;/a&gt; is a JavaScript testing library created by the same company behind React: Facebook. But while Jest was created by the same developers who created React, it is not limited to only React — it can also be used with other frameworks like Node, Angular, Vue.js, and Babel.&lt;/p&gt;

&lt;p&gt;Jest is a great tool for testing, with many advantages that make it an ideal choice for both front-end and back-end testing. Its ease of use, time-saving features, and lack of dependence on third-party tools make it an attractive option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting started with Jest&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Jest is included by default when initializing a React native app using &lt;code&gt;npx react-native init Projectname&lt;/code&gt;. However, when manually installing Jest with &lt;code&gt;npm&lt;/code&gt;, use the provided command to install it as a developer dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For TypeScript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev ts-jest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example App&lt;/strong&gt;&lt;br&gt;
For this tutorial, we are going to use &lt;a href="https://github.com/Rushit013/RNJestUnitTesting.git"&gt;this&lt;/a&gt; simple app, but of course, you can apply everything learned in any app you want.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Math function Testing!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For our first test, let’s test some math functions. Classic.&lt;/p&gt;

&lt;p&gt;To understand the scenario let’s create &lt;strong&gt;maths.js&lt;/strong&gt; which includes the math functions, and &lt;strong&gt;Math-test.js&lt;/strong&gt; which includes the test case to test the math function of the &lt;strong&gt;maths.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// maths.ts
export const add = (a: number, b: number) =&amp;gt; {
  const result = a + b;
  return result;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s move on to creating our test cases! To start, simply import the math functions into the &lt;strong&gt;Math-test.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Math-test.js
import {add} from '../src/utils/maths';

it('addition should return 4', () =&amp;gt; {
  const a = 2;
  const b = 2;

  expect(add(a, b)).toBe(4);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is your standard it call (you can also use test). If we analyze this, it is a function that receives two arguments: a string for the test description, and a callback function that will be called when the test runs. on expect we are checking whether the math function gives the correct result.&lt;/p&gt;

&lt;p&gt;Now let’s run this command in the terminal to run test cases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zscYov1D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0zqizlp9e2vokxbw2wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zscYov1D--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0zqizlp9e2vokxbw2wg.png" alt="Image description" width="800" height="169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, we can see all test cases passing. :)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Login functionality Testing!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For our second test, let’s test the real-world scenario of the login screen.&lt;/p&gt;

&lt;p&gt;To understand the scenario let’s create &lt;strong&gt;login.js&lt;/strong&gt; which includes the login validation functions, and &lt;strong&gt;Login-test.js&lt;/strong&gt; which includes the test case to test the login function of the &lt;strong&gt;login.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// login.js
export const LoginValidations = () =&amp;gt; {
  const isEmailValid = (text: string) =&amp;gt; /@/.test(text);
  const isPasswordValid = (password: string) =&amp;gt; password.length &amp;gt;= 8;
  const areFormFieldsValid = (email: string, password: string) =&amp;gt;
    isEmailValid(email) &amp;amp;&amp;amp; isPasswordValid(password);

  return {
    isEmailValid,
    isPasswordValid,
    areFormFieldsValid,
  };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s move on to creating our test cases! To start, simply import the login functions into the &lt;strong&gt;Login-test.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Login-test.js
import {LoginValidations} from '../src/utils/login';

const {areFormFieldsValid, isEmailValid, isPasswordValid} = LoginValidations();

it('should be a valid email', () =&amp;gt; {
  expect(isEmailValid('jhondoe@gmail.com')).toBeTruthy();
});

/**
 * We want to be sure to handle failure as well
 */
it('should not be a valid email', () =&amp;gt; {
  expect(isEmailValid('jhondoe.gmail.com')).toBeFalsy();
});

///

it('should be a valid password', () =&amp;gt; {
  expect(isPasswordValid('12345678')).toBeTruthy();
});
it('should not be a valid password', () =&amp;gt; {
  expect(isPasswordValid('1234')).toBeFalsy();
});

////

it('should be valid fields', () =&amp;gt; {
  expect(areFormFieldsValid('jhondoe@gmail.com', '12345678')).toBeTruthy();
});
it('should not be valid fields', () =&amp;gt; {
  expect(areFormFieldsValid('jhondoe.gmail.com', '12378')).toBeFalsy();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;.toBeTruthy&lt;/code&gt; is a great way to ensure a value is true in a Boolean context when you’re not concerned with the specific value. The same goes for &lt;code&gt;.toBeFalsy&lt;/code&gt; used to ensure a value is false in a Boolean context when you’re not concerned with the specific value.&lt;/p&gt;

&lt;p&gt;We can see how our tests run successfully:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gkqU-9-H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v58l310h4n91zrjs8fmc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gkqU-9-H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v58l310h4n91zrjs8fmc.png" alt="Image description" width="800" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Network call Testing!&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For our third test, let’s test the real-world scenario of the network call.&lt;/p&gt;

&lt;p&gt;To understand the scenario let’s create &lt;strong&gt;ApiHelper.js&lt;/strong&gt; which includes the simple API call, and &lt;strong&gt;Dashboard-test.js&lt;/strong&gt; which includes the test case to test the API function of the &lt;strong&gt;ApiHelper.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ApiHelper.js
import Http from '../utils/http';

export default {
  getStoriesOfSection: (page: number) =&amp;gt; {
    return Http.request({
      url: `https://randomuser.me/api?lego&amp;amp;randomapi?results=${page}&amp;amp;results=10&amp;amp;seed=abc`, //api token here should store at BE
    });
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s move on to creating our test cases! To start, simply import the network call functions into the &lt;strong&gt;Dashboard-test.js&lt;/strong&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Dashboard-test.js
import ApiHelper from '../src/service/ApiHelper';

// API test
describe('Test API', () =&amp;gt; {
  const TEST_CASE = [1, 2, 3, 4];
  TEST_CASE.forEach((item, index) =&amp;gt; {
    test(`Test case ${index}: ${item}`, () =&amp;gt; {
      return ApiHelper.getStoriesOfSection(item).then(res =&amp;gt; {
        expect(res).toBeTruthy();
      });
    });
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When writing test cases, you might want to break your test suite into components using describe. For instance, you could use a &lt;code&gt;describe&lt;/code&gt; block for each function in your user-facing class to better organize your tests based on your specific test strategy.&lt;/p&gt;

&lt;p&gt;If you run the test now, you will see the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1q107a7h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kkjp2mkglrog3vuse5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1q107a7h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kkjp2mkglrog3vuse5l.png" alt="Image description" width="800" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that’s that! In this post, we covered the basics of the Jest framework and how it could be used for testing simple JavaScript files. Keep in mind that well-structured code is easier to test. If testing is difficult, consider breaking the code into smaller, more manageable components. Remember, tests should enhance your app, not burden it.&lt;/p&gt;

&lt;p&gt;This article offers an overview of React Native testing, but there’s so much more to learn! I encourage you to explore other testing techniques and tools, like &lt;a href="https://jestjs.io/docs/snapshot-testing"&gt;Snapshot Testing&lt;/a&gt;, &lt;a href="https://github.com/wix/Detox"&gt;Detox&lt;/a&gt;, and &lt;a href="https://github.com/callstack/react-native-testing-library"&gt;React Native Testing Library&lt;/a&gt;. Choose the ones that work best for your project, and keep learning!&lt;/p&gt;

&lt;p&gt;I hope this article has brought some new knowledge your way today. If you found it enjoyable and helpful, please don’t hesitate to give me a couple of reaction! 🦄&lt;/p&gt;

&lt;p&gt;Happy Coding :)&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>testing</category>
      <category>tutorial</category>
      <category>unittest</category>
    </item>
  </channel>
</rss>
