<?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: Lyan Chin</title>
    <description>The latest articles on DEV Community by Lyan Chin (@bounceru).</description>
    <link>https://dev.to/bounceru</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%2F742514%2F7fefd3f9-744a-4790-a7ea-aa08637d6f87.png</url>
      <title>DEV Community: Lyan Chin</title>
      <link>https://dev.to/bounceru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bounceru"/>
    <language>en</language>
    <item>
      <title>5 Easy-to-Use React Native Calendar Libraries</title>
      <dc:creator>Lyan Chin</dc:creator>
      <pubDate>Wed, 15 Dec 2021 16:28:04 +0000</pubDate>
      <link>https://dev.to/bounceru/5-easy-to-use-react-native-calendar-libraries-4h5f</link>
      <guid>https://dev.to/bounceru/5-easy-to-use-react-native-calendar-libraries-4h5f</guid>
      <description>&lt;p&gt;When building an application,&lt;/p&gt;

&lt;p&gt;you may need to allow your users to select a date or time for something to happen.&lt;br&gt;
To input the date, it’s a good idea to use a calendar picker. A calendar picker is a component used to accept date and time inputs. It lets users select present, past, or future dates with an interactive calendar.&lt;/p&gt;

&lt;p&gt;In this post, we’ll take a look at a few easy-to-use React Native calendar pickers, and then cover how to interact with the users’ on-device calendars. We’ll also walk through an example of how to build a simple app to remember your friends’ birthdays.&lt;br&gt;
Before we get started, let’s take a look at some of the benefits of using a calendar picker in your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why You Should Use a Calendar Picker
&lt;/h2&gt;

&lt;h3&gt;
  
  
  User Interface
&lt;/h3&gt;

&lt;p&gt;A calendar picker is a dedicated UI component for date and time input. A calendar picker offers an interactive calendar that users of your app can use to select dates. Users can select year, month, and day from the calendar.&lt;br&gt;
In addition, a calendar picker delivers a visually appealing UI. Some calendar pickers provide a clean modal that is dismissed after a user selects the date. This saves space for other elements on the screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nature of the Input
&lt;/h3&gt;

&lt;p&gt;A calendar picker provides a more standard format for the data a user will input. For example, users don’t have to worry about whether they’re expected to specify the value for the day before the month. Using a calendar picker eliminates any room for this kind of inconsistency in the nature of the input.&lt;/p&gt;

&lt;h3&gt;
  
  
  User Experience
&lt;/h3&gt;

&lt;p&gt;Calendar picker leads to a better overall user experience. For instance, most React Native calendar pickers use native platform date input components that users are already familiar with.&lt;br&gt;
Pulling out the virtual keyboard to input the date and time involves more steps. Hence, numeric controls can be painful and slow on mobile.&lt;br&gt;
Now let’s take a look at some React Native calendar pickers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Easy-to-Use React Native Calendar Pickers
&lt;/h3&gt;

&lt;p&gt;In this section, we’ll discuss five React Native calendar pickers that are very easy to use. The pickers on our list here are listed in no particular order.&lt;/p&gt;

&lt;h3&gt;
  
  
  React Native CalendarPicker
&lt;/h3&gt;

&lt;p&gt;First on our list is &lt;a href="https://github.com/stephy/CalendarPicker" rel="noopener noreferrer"&gt;React Native CalendarPicker&lt;/a&gt; by Stephani Bishop. The library provides a simple third-party React Native calendar picker component.&lt;br&gt;
Some of the things that make this library easy to use are the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The library is supported in Expo Go.&lt;/li&gt;
&lt;li&gt;It’s easy to implement. All you need to do is add a CalendarPicker component to your view.&lt;/li&gt;
&lt;li&gt;The library is in active development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this package, users can pick dates using an interactive touch calendar with options for users to pick the year, month, and day.&lt;/p&gt;

&lt;h3&gt;
  
  
  React Native Calendars
&lt;/h3&gt;

&lt;p&gt;The next calendar picker we’ll be discussing is React Native Calendars. React Native Calendars is a collection of customizable React Native calendar components. The components include the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calendar component&lt;/li&gt;
&lt;li&gt;CalendarList component&lt;/li&gt;
&lt;li&gt;Agenda component&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This module can be added to any React Native project with two easy steps.&lt;br&gt;
First, install the module, then add the specific component you’re interested in.&lt;br&gt;
This library offers a touch-based calendar that’s highly customizable. It also has support for multiple languages, including English, French, and Spanish.&lt;br&gt;
React Native Calendars does not support Expo Go. However, it can be used with &lt;a href="https://docs.expo.dev/build/introduction/" rel="noopener noreferrer"&gt;EAS Build&lt;/a&gt; and &lt;a href="https://docs.expo.dev/clients/introduction/" rel="noopener noreferrer"&gt;custom clients&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  React Native Modal Datetime Picker
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/mmazzarolo/react-native-modal-datetime-picker" rel="noopener noreferrer"&gt;React Native Modal Datetime Picker&lt;/a&gt; is a cross-platform calendar picker for React Native. The library includes a calendar picker component and a time picker component.&lt;br&gt;
The calendar picker for this library is presented inside a modal, which looks and feels like native modals for iOS and Android.&lt;br&gt;
React Native Modal Datetime is easy to install and supports projects created with &lt;a href="https://docs.expo.io/workflow/expo-cli/" rel="noopener noreferrer"&gt;Expo CLI&lt;/a&gt; and bare React Native projects.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>programming</category>
    </item>
    <item>
      <title>A few weeks maintaining React components, using various approaches</title>
      <dc:creator>Lyan Chin</dc:creator>
      <pubDate>Tue, 14 Dec 2021 08:47:47 +0000</pubDate>
      <link>https://dev.to/bounceru/a-few-weeks-maintaining-react-components-using-various-approaches-8l4</link>
      <guid>https://dev.to/bounceru/a-few-weeks-maintaining-react-components-using-various-approaches-8l4</guid>
      <description>&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;This post is a short made-up, based on a real experience. It aims to show different approaches to developing and maintaining React components in an application.&lt;/p&gt;

&lt;p&gt;In order to use &lt;a href="https://react-select.com/" rel="noopener noreferrer"&gt;react-select&lt;/a&gt; in a french government project, we have to translate placeholders and other default options. As far as I know, there is no i18n extension for react-select; anyway, it may not have fit our need since there may be some domain-specific text. Here we go, let's use the component's props:&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;Select
  loadingMessage={() =&amp;gt; "Chargement…"}
  noOptionsMessage={() =&amp;gt; "Aucun résultat"}
  placeholder="Choisissez une valeur"
  // …
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works.&lt;/p&gt;

&lt;h4&gt;
  
  
  👉 Now, we want to re-use this component with same options elsewhere, then everywhere else.
&lt;/h4&gt;

&lt;h2&gt;
  
  
  Week 1 - Create a custom select component
&lt;/h2&gt;

&lt;p&gt;We could create a &lt;code&gt;MySelect&lt;/code&gt;that has some default options. Since the only thing that changes for each instance are the name and the change handler, we need two props:&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 MySelect({ name, onChange }) {
  return (
    &amp;lt;Select
      loadingMessage={() =&amp;gt; "Chargement…"}
      noOptionsMessage={() =&amp;gt; "Aucun résultat"}
      placeholder="Choisissez une valeur"
      name={name}
      onChange={onChange}
    /&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thus, we could use it in various files and components:&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;MySelect name="user" onChange={(v) =&amp;gt; setUser(v)} /&amp;gt;


&amp;lt;label&amp;gt;Liste des projets&amp;lt;/label&amp;gt;
&amp;lt;MySelect 
  name="project" 
  onChange={(v) =&amp;gt; setProject(v)} 
/&amp;gt;


// Another file
&amp;lt;MySelect name="foo" onChange={bar} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It still works, it is factorized, well done!&lt;/p&gt;

&lt;p&gt;In order to add new options we could add new properties.&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 MySelect({ 
  name, 
  onChange, 
  value, 
}) {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then…&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 MySelect({ 
  name, 
  onChange, 
  value, 
  customStyles = [],
}) {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And so on…&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 MySelect({ 
  name, 
  onChange, 
  value, 
  customStyles = [],
  disabled = false,
  // etc.
}) {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🙅 OK, let's refactor it! It does not scale anymore. ❌
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Week 2 - Passing props down to a custom component
&lt;/h2&gt;

&lt;p&gt;Since adding properties seems like a useless layer over the MySelect component, let's just pass props to the component thanks to &lt;a href="**https://reactjs.org/docs/jsx-in-depth.html#spread-attributes**"&gt;spread operator&lt;/a&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 MySelect(props) {
  return (
    &amp;lt;Select
      loadingMessage={() =&amp;gt; "Chargement…"}
      noOptionsMessage={() =&amp;gt; "Aucun résultat"}
      placeholder="Choisissez une valeur"
      {...props}
    /&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We just removed some complexity, that seems easier to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 3 - Specialization
&lt;/h2&gt;

&lt;p&gt;A few days later, we figure out that we are repeating code by writing the same sub-component again and again:&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;MySelect
  isSearchable
  isClearable
  isMulti
  name="products"
  // …
/&amp;gt;

&amp;lt;MySelect
  isSearchable
  isClearable
  isMulti
  name="services"
  // …
/&amp;gt;

&amp;lt;MySelect
  isSearchable
  isClearable
  isMulti
  name="things"
  // …
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems many MySelect needs the same 3 attributes: &lt;code&gt;isSearchable&lt;/code&gt;, &lt;code&gt;isClearable&lt;/code&gt;, &lt;code&gt;isMulti&lt;/code&gt;. We could create a new component that looks like &lt;code&gt;MySelect&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;export default function MySearchableSelect(props) {
  return (
    &amp;lt;Select
      loadingMessage={() =&amp;gt; "Chargement…"}
      noOptionsMessage={() =&amp;gt; "Aucun résultat"}
      placeholder="Choisissez une valeur"
      isSearchable
      isClearable
      isMulti
      {...props}
    /&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Still, MySearchableSelect has some code in common with MySelect so maybe we could consider MySearchableSelect should render a specific version of MySelect (specialization):&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 MySearchableSelect(props) {
  return (
    &amp;lt;MySelect
      isSearchable
      isClearable
      isMulti
      {...props}
    /&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach seems compatible with the DRY principle. However, it makes the code harder to debug after a few more days. When we have a problem in a code that uses MySearchableSelect component, we may have to jump to MySearchableSelect, then MySelect, then Select and back again to understand where the problem is and to choose where to fix it. The code is oversimplified in this example: in a real-world example, it could take some time to debug. There is also a risk to create MyCreatableSelect, MySearchableAndCreatableSelect and so on. As a side note, using DRY as a main principle could be considered harmful.&lt;/p&gt;

&lt;p&gt;Maybe we could remove abstraction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Week 4 - Adding conditions
&lt;/h2&gt;

&lt;p&gt;To avoid this complexity, we could get rid of MyCreatableSelect, then add a boolean prop to MySelect that allows handling the case where MySelect is a specialized component:&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 MySelect({ 
  searchable = false
  ...props
}) {
  let searchableProps = {};
  if (searchable) {
    searchableProps = {
      isSearchable: true,
      isClearable: true,
      isMulti: true,
    };
  }
  return (
    &amp;lt;Select
      loadingMessage={() =&amp;gt; "Chargement…"}
      noOptionsMessage={() =&amp;gt; "Aucun résultat"}
      placeholder="Choisissez une valeur"
      {...searchableProps}
      {...props}
    /&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>Comparison between ReactJS and React Native</title>
      <dc:creator>Lyan Chin</dc:creator>
      <pubDate>Wed, 01 Dec 2021 17:16:21 +0000</pubDate>
      <link>https://dev.to/bounceru/comparison-between-reactjs-and-react-native-1gij</link>
      <guid>https://dev.to/bounceru/comparison-between-reactjs-and-react-native-1gij</guid>
      <description>&lt;p&gt;You must have been confused between &lt;a href="https://externlabs.com/blogs/difference-react-vs-react-native/" rel="noopener noreferrer"&gt;React and React Native&lt;/a&gt;; They don’t just share the same name, but the same logo too, gets mentioned same time. In this article, we will be comparing React and React Native. First, know what exactly are they:&lt;/p&gt;

&lt;p&gt;What is react?&lt;/p&gt;

&lt;p&gt;Released by Facebook in 2013, &lt;a href="https://externlabs.com/blogs/what-is-react-used-for/" rel="noopener noreferrer"&gt;React is a JavaScript library&lt;/a&gt; for modern apps and web development. React is used to handle the view layer and can be used to develop both web and mobile applications. In addition, there is a mobile-specific react framework for mobile app development named ‘React Native.’&lt;/p&gt;

&lt;p&gt;What is React Native?&lt;/p&gt;

&lt;p&gt;Unlike React, React Native is built for Cross-platform Mobile App Development. It Primarily uses React and react’s libraries for mobile development. React Native opens developers to react components to build a mobile app for different platforms, including Android, iPhone, iPad, Windows, and Linux. React Native can forge the full potential of React in its framework.&lt;/p&gt;

&lt;p&gt;The difference between ReactJS &amp;amp; React Native&lt;/p&gt;

&lt;p&gt;ReactJS&lt;/p&gt;

&lt;p&gt;ReactJS is a popular choice when it comes to a front end &amp;amp; single page development; Here is why:&lt;/p&gt;

&lt;p&gt;Fast &amp;amp; efficient development&lt;/p&gt;

&lt;p&gt;React requires less coding while providing more functionalities in even dynamic app development, unlike JavaScript, which includes complex codings.&lt;/p&gt;

&lt;p&gt;Better Performance&lt;/p&gt;

&lt;p&gt;React works with Virtual DOM, which makes web and app development faster. Virtual DOM compares the components’ regular and previous states and only updates necessary components instead of updating the whole program and providing developers faster results with less work.&lt;/p&gt;

&lt;p&gt;Easy &amp;amp; Fast Adoption&lt;/p&gt;

&lt;p&gt;React is easy to learn because it mostly contains basic HTML and JavaScript components with some valuable additions. Thus, you can learn and adapt to work with ReactJS’s library in a short time.&lt;br&gt;
Reusable Codes&lt;br&gt;
Components and codes are building blocks that build any react application, and even a single app contains multiple components and codes. Every component and code have their control and logic; react then can be used throughout the application, which helps to reduce development time.&lt;/p&gt;

&lt;p&gt;Unidirectional Data Flow&lt;/p&gt;

&lt;p&gt;ReactJS follows a unidirectional data flow system. React allows parent components to nest child components. When Data flows in a single direction, debugging and fixing become much more accessible. Developers can trach errors in apps at the exact moment they appear.&lt;/p&gt;

&lt;p&gt;Dedicated Tools for Debug&lt;/p&gt;

&lt;p&gt;Facebook provided react community a Chrome browser extension that allows debugging React applications within browsers. One more reason to choose reactJS over others.&lt;/p&gt;

&lt;p&gt;React Native&lt;/p&gt;

&lt;p&gt;Based on JavaScript&lt;/p&gt;

&lt;p&gt;React Native is also written in JavaScript like React, which helps developers in easier coding. JavaScript Developers find it familiar after first use.&lt;/p&gt;

&lt;p&gt;One Development and Many Platform&lt;/p&gt;

&lt;p&gt;It’s a cross platform app development framework. You have to develop your product one, and you can run it on other platforms without separate development; Thus, fast and convenient development.&lt;/p&gt;

&lt;p&gt;Wider Community Support&lt;/p&gt;

&lt;p&gt;React Native is backed by Facebook, Which continuously makes improvements and updates. In addition, It has a wide community using and working with React Native, including over 45,000 members. Users and openly askes in community channels and get support from this wide community.&lt;/p&gt;

&lt;p&gt;Still Needs some Improvements&lt;/p&gt;

&lt;p&gt;React Native still doesn’t include many useful modules and plug-ins, So you might end up somewhere between development. You can reach community channels for help or a professional React Native Developer. If you are a React expert, it won’t be a problem because React Native supports React Elements.&lt;br&gt;
As a wise man said, ‘No one is perfect; So React Native is. It has some drawbacks, but still, it has to offer more than any other framework out there.&lt;/p&gt;

&lt;p&gt;ReactJS vs. React Native&lt;/p&gt;

&lt;p&gt;Let’s take it Streght; React and React Native are not competitors; they are both almost the same and basically JavaScript Tools but vary differently for their specific purposes. It depends on your requirements and project, Which you should use. Here are some key differences -&lt;/p&gt;

&lt;p&gt;ReactJS Vs React Native&lt;/p&gt;

&lt;p&gt;Best for Interactive UI &amp;amp; UX development&lt;br&gt;
Best for Mobile App Development &amp;amp; Cross-Platform App&lt;br&gt;
Reusable Components&lt;br&gt;
Pre-Built Components for Convenience in Development&lt;br&gt;
Re-Useable Codes&lt;br&gt;
Fast-Rendering&lt;br&gt;
Simple UI even for New Users&lt;br&gt;
Easier Development for Cross-Platform Work&lt;br&gt;
Primarily for Web Development&lt;br&gt;
Primarily for Mobile &amp;amp; Cross-Platform App&lt;br&gt;
Basically A Library&lt;br&gt;
Basically A Framework&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Best UI LIbrary for your next React Native App</title>
      <dc:creator>Lyan Chin</dc:creator>
      <pubDate>Wed, 01 Dec 2021 17:12:16 +0000</pubDate>
      <link>https://dev.to/bounceru/best-ui-library-for-your-next-react-native-app-32al</link>
      <guid>https://dev.to/bounceru/best-ui-library-for-your-next-react-native-app-32al</guid>
      <description>&lt;p&gt;I had built multiple apps in React Native for my personal as well as Freelancing projects. I had also tried many UI libraries for React native, to get started fast and for consistent UI.&lt;/p&gt;

&lt;p&gt;I had checked UI Kitten after some time but after I had used&lt;br&gt;
UI kitten, I became a fan of this library. It has most of the components you will need, for example, Input, Card, Button, etc. It also supports the Light and Dark theme. It is the library that has its Icon Module and all the Icons are awesome. The app looks good in both the light theme and dark theme.&lt;/p&gt;

&lt;p&gt;To create a new React Native app using Kitten UI, you just need to run the below command, it will create a new React Native app with the UI kitten as the template&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx react-native init MyApp --template @ui-kitten/template-js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next post, I will try to explain, how to add UI-kitten to an already created project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://akveo.github.io/react-native-ui-kitten/" rel="noopener noreferrer"&gt;UI kitten offical page&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>mobile</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to avoid notches with Safe Area Context in React Native apps</title>
      <dc:creator>Lyan Chin</dc:creator>
      <pubDate>Tue, 02 Nov 2021 20:38:37 +0000</pubDate>
      <link>https://dev.to/bounceru/how-to-avoid-notches-with-safe-area-context-in-react-native-apps-3e3a</link>
      <guid>https://dev.to/bounceru/how-to-avoid-notches-with-safe-area-context-in-react-native-apps-3e3a</guid>
      <description>&lt;p&gt;Most devices nowadays come with a notch or some kind of status bar. Therefore, when building a mobile application using React Native, it is vital to ensure that the content of an app screen is rendered correctly across different types of devices.&lt;/p&gt;

&lt;p&gt;In this article, let's take a look two different approaches to make app screens in React Native to avoid the content being positioned behind a notch or status bar.&lt;/p&gt;

&lt;p&gt;The first approach will discuss SafeAreaView component from React Native components API. The second approach will discuss the advantage of using &lt;a href="https://github.com/th3rdwave/react-native-safe-area-context#readme" rel="noopener noreferrer"&gt;react-native-safe-area-context &lt;/a&gt; open source library and how it provides a cross-platform solution.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Notch Problem
&lt;/h3&gt;

&lt;p&gt;When you are starting to build a screen in React Native app, you might add use the following code snippet to display text:&lt;br&gt;
&lt;/p&gt;

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

export const HomeScreen = () =&amp;gt; {
  return (
    &amp;lt;View style={[styles.container]}&amp;gt;
      &amp;lt;View style={{ backgroundColor: 'blue' }}&amp;gt;
        &amp;lt;Text style={{ fontSize: 28, color: 'white' }}&amp;gt;Hello World&amp;lt;/Text&amp;gt;
      &amp;lt;/View&amp;gt;
    &amp;lt;/View&amp;gt;
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'red'
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code snippet has a parent View component with a background color of red. It wraps another View component with a background color of blue that contains a Text component to display some text on the screen.&lt;/p&gt;

&lt;p&gt;This will display the content of the app screen on an iOS device as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4sq1wa9pbk69addmy7k3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4sq1wa9pbk69addmy7k3.png" alt="Image description" width="320" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
