<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Posts | Farhan Says Hi 👋</title>
    <link>https://www.farhansayshi.com/post/</link>
      <atom:link href="https://www.farhansayshi.com/post/index.xml" rel="self" type="application/rss+xml" />
    <description>Posts</description>
    <generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><lastBuildDate>Mon, 28 Jun 2021 00:00:00 +0000</lastBuildDate>
    <image>
      <url>https://www.farhansayshi.com/images/icon_hu8796f54df518a3df870f769b6793bcca_7417_512x512_fill_lanczos_center_2.png</url>
      <title>Posts</title>
      <link>https://www.farhansayshi.com/post/</link>
    </image>
    
    <item>
      <title>Using Material Design / Material UI in a React Native App</title>
      <link>https://www.farhansayshi.com/post/using-material-design-and-material-ui-in-react-native/</link>
      <pubDate>Mon, 28 Jun 2021 00:00:00 +0000</pubDate>
      <guid>https://www.farhansayshi.com/post/using-material-design-and-material-ui-in-react-native/</guid>
      <description>&lt;p&gt;&lt;em&gt;This post originally appeared as 
&lt;a href=&#34;https://blog.logrocket.com/using-material-ui-in-react-native/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Using Material UI in React Native&lt;/a&gt; on 
&lt;a href=&#34;https://blog.logrocket.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;blog.logrocket.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re building a cross-platform mobile app, it&amp;rsquo;s a good idea to base your
app&amp;rsquo;s UI/UX on &lt;strong&gt;
&lt;a href=&#34;https://material.io/design&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Material Design&lt;/a&gt;&lt;/strong&gt;, Google&amp;rsquo;s own
design language, which it uses in all its mobile apps. The most popular
mobile apps heavily use Material Design concepts: Whatsapp, Uber, Lyft,
Google Maps, SpotAngels, etc. This means your users are already familiar with
the look and feel of Material Design, and they will understand how to use
your app more easily if you adhere to the design language of their favorite,
most commonly used apps.&lt;/p&gt;
&lt;p&gt;The heavy hitter of Material Design component libraries on React Native is
&lt;strong&gt;
&lt;a href=&#34;https://reactnativepaper.com&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;react-native-paper&lt;/a&gt;&lt;/strong&gt;, and this guide will
focus on using react-native-paper to set up a starter app with the some of
the most prominent and recognizable Material Design features: Hamburger Menu,
Drawer Navigation, FAB (Floating Action Button), and Contextual Action Bar.&lt;/p&gt;
&lt;h2 id=&#34;sections----omit-in-toc---&#34;&gt;Sections &lt;!-- omit in toc --&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#demo&#34;&gt;Demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#setup&#34;&gt;Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#initial-screens&#34;&gt;Initial Screens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#hamburger-menu--drawer-navigation&#34;&gt;Hamburger Menu / Drawer Navigation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#floating-action-button-fab&#34;&gt;Floating Action Button (FAB)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#contextual-action-bar&#34;&gt;Contextual Action Bar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#theming&#34;&gt;Theming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;demo&#34;&gt;Demo&lt;/h2&gt;
&lt;p&gt;This is what the starter app I&amp;rsquo;m going to build will eventually look like.
All the code for this demo is available in this GitHub repo:

&lt;a href=&#34;https://github.com/kathawala/material-ui-in-react-native&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;material-ui-in-react-native&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/full_demo_small.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;
&lt;p&gt;First, I&amp;rsquo;ll initialize my React Native app using 
&lt;a href=&#34;https://expo.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Expo&lt;/a&gt;.
You don&amp;rsquo;t have to use Expo, it just helps me get started, so I can focus on
the UI in this example.&lt;/p&gt;
&lt;p&gt;If you don&amp;rsquo;t have &lt;code&gt;expo-cli&lt;/code&gt; installed, then first run:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;npm install -g expo-cli 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now run the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;expo init material-ui-in-react-native -t expo-template-blank-typescript
cd material-ui-in-react-native
yarn add react-native-paper 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    You can also follow these
&lt;a href=&#34;https://callstack.github.io/react-native-paper/getting-started.html&#34;&gt;additional installation instructions&lt;/a&gt;
to enable tree-shaking, reduce bundle-size, etc. with react-native-paper
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;rsquo;m also adding 
&lt;a href=&#34;https://reactnavigation.org/docs/getting-started&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;&lt;strong&gt;react-navigation&lt;/strong&gt;&lt;/a&gt;
to this project. I recommend you use it as well. It&amp;rsquo;s the most popular
navigation library for React Native, and there&amp;rsquo;s more support for running it
alongside react-native-paper compared to other navigation libraries. Follow

&lt;a href=&#34;https://reactnavigation.org/docs/getting-started/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;the installation instructions for react-navigation&lt;/a&gt;,
since they are slightly different, depending on whether you use Expo or plain
React Native.&lt;/p&gt;
&lt;h2 id=&#34;initial-screens&#34;&gt;Initial Screens&lt;/h2&gt;
&lt;p&gt;Create the following two files in your app&amp;rsquo;s main directory (if you want the
styles used, remember, everything for this example is available in 
&lt;a href=&#34;https://github.com/kathawala/material-ui-in-react-native&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this
GitHub repo&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;MyFriends.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;Title&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;base&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./styles/base&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IMyFriendsProps&lt;/span&gt; {}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IMyFriendsProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;base&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;centered&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Title&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Title&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;Profile.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;Title&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;base&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./styles/base&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IProfileProps&lt;/span&gt; {}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Profile&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IProfileProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;base&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;centered&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Title&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Profile&lt;/span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Title&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Profile&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Over the course of this guide, I&amp;rsquo;ll link these screens to each other using a
Navigation Drawer (or Hamburger Menu) and add Material UI components to each
of them.&lt;/p&gt;
&lt;h2 id=&#34;hamburger-menu--drawer-navigation&#34;&gt;Hamburger Menu / Drawer Navigation&lt;/h2&gt;
&lt;p&gt;Material Design promotes the usage of a
&lt;strong&gt;
&lt;a href=&#34;https://material.io/components/navigation-drawer&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Navigation Drawer&lt;/a&gt;&lt;/strong&gt;,
so I&amp;rsquo;ll use this type of UI to make the &lt;em&gt;My Friends&lt;/em&gt; and &lt;em&gt;Profile&lt;/em&gt; screens
navigable to and from each other.&lt;/p&gt;
&lt;p&gt;First, I&amp;rsquo;ll add React Navigation&amp;rsquo;s &lt;code&gt;drawer&lt;/code&gt; library:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;  yarn add @react-navigation/native @react-navigation/drawer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now I&amp;rsquo;ll add the following into my &lt;code&gt;App.tsx&lt;/code&gt; to enable Drawer Navigation.
It should look like the following:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;App.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;createDrawerNavigator&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/drawer&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationContainer&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;StatusBar&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-status-bar&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;SafeAreaProvider&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-safe-area-context&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./MyFriends&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Profile&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./Profile&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App() {&lt;/span&gt;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Drawer&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;createDrawerNavigator&lt;/span&gt;();
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;SafeAreaProvider&lt;/span&gt;&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;NavigationContainer&lt;/span&gt;&amp;gt;
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
          &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Screen&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;My Friends&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;component&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;} /&amp;gt;
          &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Screen&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;name&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Profile&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;component&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;Profile&lt;/span&gt;} /&amp;gt;
        &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
      &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;NavigationContainer&lt;/span&gt;&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;StatusBar&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;auto&amp;#39;&lt;/span&gt; /&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;SafeAreaProvider&lt;/span&gt;&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This drawer also needs a button to open it. That button should look like the
classic hamburger icon (≡) and it should open the navigation drawer when
pressed. Here&amp;rsquo;s what that button might look like:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;components/MenuIcon.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;IconButton&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;DrawerActions&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;useNavigation&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuIcon() {&lt;/span&gt;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useNavigation&lt;/span&gt;();

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;openDrawer&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;(() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;dispatch&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;DrawerActions&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;openDrawer&lt;/span&gt;());
  }, []);

  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IconButton&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;menu&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;size&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#ae81ff&#34;&gt;24&lt;/span&gt;} &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;openDrawer&lt;/span&gt;} /&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A few things to notice here:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;React-navigation&amp;rsquo;s &lt;strong&gt;&lt;code&gt;useNavigation&lt;/code&gt;&lt;/strong&gt; hook is how we are going to execute most navigation actions, from changing screens to opening drawers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The &lt;strong&gt;&lt;code&gt;&amp;lt;IconButton&amp;gt;&lt;/code&gt;&lt;/strong&gt; component is from react-native-paper. It supports
all the 
&lt;a href=&#34;https://materialdesignicons.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Material Design icons&lt;/a&gt; by name and
optionally supports any ReactNode that you want to pass in there, which
allows one to add in any desired icon from any third-party library.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now I&amp;rsquo;ll add my &lt;code&gt;&amp;lt;MenuIcon&amp;gt;&lt;/code&gt; to my Navigation Drawer by replacing this from
&lt;code&gt;App.tsx&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
    ...
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuIcon&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./components/MenuIcon.tsx&amp;#39;&lt;/span&gt;;
...
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;screenOptions&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;headerShown&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;headerLeft&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MenuIcon&lt;/span&gt; /&amp;gt;}}
  &amp;gt;
    ...
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Lastly, I can customize my Navigation Drawer using the &lt;code&gt;drawerContent&lt;/code&gt; prop
of the same &lt;code&gt;&amp;lt;Drawer.Navigator&amp;gt;&lt;/code&gt; component I just altered.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll show an example which adds a header image to the top of the drawer. Feel
free to customize with whatever you want to put in the drawer:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;components/MenuContent.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DrawerContentComponentProps&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DrawerContentScrollView&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DrawerItemList&lt;/span&gt;,
} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/drawer&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;Image&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuContent&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;DrawerContentComponentProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (
  &lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;
) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;DrawerContentScrollView&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;...props&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Image&lt;/span&gt;
        &lt;span style=&#34;color:#a6e22e&#34;&gt;resizeMode&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;cover&amp;#39;&lt;/span&gt;
        &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;width&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;100%&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;height&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;140&lt;/span&gt;}}
        &lt;span style=&#34;color:#a6e22e&#34;&gt;source&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;require&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;../assets/drawerHeaderImage.jpg&amp;#39;&lt;/span&gt;)}
      /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;DrawerItemList&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;...props&lt;/span&gt;} /&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;DrawerContentScrollView&lt;/span&gt;&amp;gt;
  );
};
&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuContent&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now I&amp;rsquo;ll pass &lt;code&gt;&amp;lt;MenuContent&amp;gt;&lt;/code&gt; into &lt;code&gt;&amp;lt;Drawer.Navigator&amp;gt;&lt;/code&gt;.
To do this, I&amp;rsquo;ll make the following change in &lt;code&gt;App.tsx&lt;/code&gt; from this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuIcon&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./components/MenuIcon.tsx&amp;#39;&lt;/span&gt;;
...
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;screenOptions&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;headerShown&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;headerLeft&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MenuIcon&lt;/span&gt; /&amp;gt;}}
  &amp;gt;
    ...
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;to this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuIcon&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./components/MenuIcon.tsx&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MenuContent&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./components/MenuContent.tsx&amp;#39;&lt;/span&gt;;
...
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;screenOptions&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;headerShown&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;headerLeft&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MenuIcon&lt;/span&gt; /&amp;gt;}}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;drawerContent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{(&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MenuContent&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;...props&lt;/span&gt;} /&amp;gt;}
  &amp;gt;
    ...
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Drawer.Navigator&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And now, I have fully functioning Drawer Navigation with a custom image
header. Here&amp;rsquo;s the result:&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/drawer-screencap-small.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;p&gt;Next, I&amp;rsquo;ll flesh out the main screens with more Material Design concepts.&lt;/p&gt;
&lt;h2 id=&#34;floating-action-button-fab&#34;&gt;Floating Action Button (FAB)&lt;/h2&gt;
&lt;p&gt;One of the hallmarks of Material Design is the Floating Action Button
(or FAB). The &lt;code&gt;&amp;lt;FAB&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;FAB.Group&amp;gt;&lt;/code&gt; components provide a useful
implementation of the Floating Action Button according to Material Design
principles. With minimal setup, I&amp;rsquo;ll add this to the &lt;em&gt;My Friends&lt;/em&gt; screen
right now.&lt;/p&gt;
&lt;p&gt;First, I&amp;rsquo;ll need to add the &lt;code&gt;&amp;lt;Provider&amp;gt;&lt;/code&gt; component from react-native-paper
and wrap that component around the &lt;code&gt;&amp;lt;NavigationContainer&lt;/code&gt;&amp;gt; in &lt;code&gt;App.tsx&lt;/code&gt; as
follows:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;App.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;Provider&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;

...
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Provider&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;NavigationContainer&lt;/span&gt;&amp;gt;
      ...
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;NavigationContainer&lt;/span&gt;&amp;gt;
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Provider&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now I&amp;rsquo;ll add my Floating Action Button to the &lt;em&gt;My Friends&lt;/em&gt; screen. I need&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;Portal&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;FAB.Group&amp;gt;&lt;/code&gt; components from react-native-paper&lt;/li&gt;
&lt;li&gt;A state variable &lt;code&gt;fabIsOpen&lt;/code&gt; to keep track of whether the FAB is open or
closed&lt;/li&gt;
&lt;li&gt;Some information about whether or not this screen is currently visible to
the user (&lt;code&gt;isScreenFocused&lt;/code&gt;). I need &lt;code&gt;isScreenFocused&lt;/code&gt; because without it, I
might end up with the FAB being visible on other screens than the
&lt;em&gt;My Friends&lt;/em&gt; screen&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here’s what the &lt;em&gt;My Friends&lt;/em&gt; screen looks like with all that added in:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;MyFriends.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;useIsFocused&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt;, {&lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;FAB&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Portal&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Title&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;base&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./styles/base&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IMyFriendsProps&lt;/span&gt; {}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IMyFriendsProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;isScreenFocused&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useIsFocused&lt;/span&gt;();
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;fabIsOpen&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setFabIsOpen&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);

  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;base&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;centered&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Title&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Title&lt;/span&gt;&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Portal&lt;/span&gt;&amp;gt;
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;FAB.Group&lt;/span&gt;
          &lt;span style=&#34;color:#a6e22e&#34;&gt;visible&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;isScreenFocused&lt;/span&gt;}
          &lt;span style=&#34;color:#a6e22e&#34;&gt;open&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;fabIsOpen&lt;/span&gt;}
          &lt;span style=&#34;color:#a6e22e&#34;&gt;onStateChange&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{({&lt;span style=&#34;color:#a6e22e&#34;&gt;open&lt;/span&gt;}) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setFabIsOpen&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;open&lt;/span&gt;)}
          &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;fabIsOpen&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;close&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;account-multiple&amp;#39;&lt;/span&gt;}
          &lt;span style=&#34;color:#a6e22e&#34;&gt;actions&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{[
            {
              &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;plus&amp;#39;&lt;/span&gt;,
              &lt;span style=&#34;color:#a6e22e&#34;&gt;label&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Add new friend&amp;#39;&lt;/span&gt;,
              &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {},
            },
            {
              &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;file-export&amp;#39;&lt;/span&gt;,
              &lt;span style=&#34;color:#a6e22e&#34;&gt;label&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Export friend list&amp;#39;&lt;/span&gt;,
              &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {},
            },
          ]}
        /&amp;gt;
      &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Portal&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MyFriends&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now the &lt;em&gt;My Friends&lt;/em&gt; screen behaves like the following:&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/fab-screencap-small.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;p&gt;Next, I&amp;rsquo;ll add a Contextual Action Bar, which can be activated whenever an
item in one of the screens is long-pressed.&lt;/p&gt;
&lt;h2 id=&#34;contextual-action-bar&#34;&gt;Contextual Action Bar&lt;/h2&gt;
&lt;p&gt;Apps like Gmail and Google Photos make use of a Material Design concept
called the 
&lt;a href=&#34;https://material.io/components/app-bars-top#contextual-action-bar&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Contextual Action Bar&lt;/a&gt;.
I&amp;rsquo;ll implement a version of this quickly in the current app.&lt;/p&gt;
&lt;p&gt;First, I&amp;rsquo;ll build the &lt;code&gt;ContextualActionBar&lt;/code&gt; component itself using the

&lt;a href=&#34;https://callstack.github.io/react-native-paper/appbar.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Appbar component from react-native-paper&lt;/a&gt;.
It should look something like this, to start with:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;./components/ContextualActionBar.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;Appbar&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IContextualActionBarProps&lt;/span&gt; {}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ContextualActionBar&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IContextualActionBarProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (
  &lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;
) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Header&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;...props&lt;/span&gt;} &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;width&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;100%&amp;#39;&lt;/span&gt;}}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Action&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;close&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {}} /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Content&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt; /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Action&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;delete&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {}} /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Action&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;content-copy&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {}} /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Action&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;magnify&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {}} /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Action&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dots-vertical&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {}} /&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Header&lt;/span&gt;&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ContextualActionBar&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now I want this component to render on top of the given screen&amp;rsquo;s header
whenever an item is long pressed. Back in the &lt;em&gt;My Friends&lt;/em&gt; screen, I&amp;rsquo;ve added
some items for this purpose. On that screen, here&amp;rsquo;s how I&amp;rsquo;ll render the
Contextual Action Bar over the screen&amp;rsquo;s header:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;MyFriends.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;useNavigation&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ContextualActionBar&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./components/ContextualActionBar&amp;#39;&lt;/span&gt;;
...
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setCabIsOpen&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useNavigation&lt;/span&gt;();

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;openHeader&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;(() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;setCabIsOpen&lt;/span&gt;(&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;);
  }, [&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;]);

  &lt;span style=&#34;color:#a6e22e&#34;&gt;useEffect&lt;/span&gt;(() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;) {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;setOptions&lt;/span&gt;({
        &lt;span style=&#34;color:#75715e&#34;&gt;// have to use props: any since that&amp;#39;s the type signature
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;// from react-navigation...
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;header&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;any&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; (&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;ContextualActionBar&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;...props&lt;/span&gt;} /&amp;gt;),
      });
    } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;setOptions&lt;/span&gt;({&lt;span style=&#34;color:#a6e22e&#34;&gt;header&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;undefined&lt;/span&gt;});
    }
  }, [&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;]);
...
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    ...
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;List.Item&lt;/span&gt;
      &lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Friend #1&amp;#39;&lt;/span&gt;
      &lt;span style=&#34;color:#a6e22e&#34;&gt;description&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Mar 18 | 3:31 PM&amp;#39;&lt;/span&gt;
      &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{&lt;span style=&#34;color:#a6e22e&#34;&gt;width&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;100%&amp;#39;&lt;/span&gt;}}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {}}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;onLongPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;openHeader&lt;/span&gt;}
    /&amp;gt;
    ...
  );
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Above, I&amp;rsquo;m toggling a state boolean value (&lt;code&gt;cabIsOpen&lt;/code&gt;) whenever a given item
is long pressed. Based on that value, I either switch the React Navigation
header to render the  &lt;code&gt;&amp;lt;ContextualActionBar&amp;gt;&lt;/code&gt;  or switch back to render the
default React Navigation header.&lt;/p&gt;
&lt;p&gt;Now I should have a Contextual Action Bar appear when I long-press the
&amp;ldquo;Friend #1&amp;rdquo; item. However, the title is still empty and I cannot do anything
in any of the actions because the &lt;code&gt;&amp;lt;ContextualActionBar&amp;gt;&lt;/code&gt; is unaware of any
of the state of either the &amp;ldquo;Friend #1&amp;rdquo; item or the larger &lt;em&gt;My Friends&lt;/em&gt; screen
as a whole.&lt;/p&gt;
&lt;p&gt;Thus, the next step is to add pass a title into the &lt;code&gt;&amp;lt;ContextualActionBar&amp;gt;&lt;/code&gt;
and pass in a function which can close the bar and be triggered by one of the
buttons in the bar.&lt;/p&gt;
&lt;p&gt;To do this, I have to add another state variable to the &lt;em&gt;My Friends&lt;/em&gt; screen:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;selectedItemName&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setSelectedItemName&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I also need to create a function which will close the header and reset the
above state variable:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;closeHeader&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;(() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;setCabIsOpen&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
  &lt;span style=&#34;color:#a6e22e&#34;&gt;setSelectedItemName&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;#39;&lt;/span&gt;);
}, []);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then I need to pass both &lt;code&gt;selectedItemName&lt;/code&gt; and &lt;code&gt;closeHeader&lt;/code&gt; as props to
&lt;code&gt;&amp;lt;ContextualActionBar&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;useEffect&lt;/span&gt;(() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;) {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;setOptions&lt;/span&gt;({
      &lt;span style=&#34;color:#a6e22e&#34;&gt;header&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;any&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; (
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;ContextualActionBar&lt;/span&gt;
          {&lt;span style=&#34;color:#a6e22e&#34;&gt;...props&lt;/span&gt;}
          &lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;selectedItemName&lt;/span&gt;}
          &lt;span style=&#34;color:#a6e22e&#34;&gt;close&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;closeHeader&lt;/span&gt;}
        /&amp;gt;
      ),
    });
  } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;navigation&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;setOptions&lt;/span&gt;({&lt;span style=&#34;color:#a6e22e&#34;&gt;header&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;undefined&lt;/span&gt;});
  }
}, [&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;selectedItemName&lt;/span&gt;]);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Lastly, I need to set &lt;code&gt;selectedItemName&lt;/code&gt; to the title of the item that&amp;rsquo;s been
long pressed:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;openHeader&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;((&lt;span style=&#34;color:#a6e22e&#34;&gt;str&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;setSelectedItemName&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;str&lt;/span&gt;);
  &lt;span style=&#34;color:#a6e22e&#34;&gt;setCabIsOpen&lt;/span&gt;(&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;);
}, [&lt;span style=&#34;color:#a6e22e&#34;&gt;cabIsOpen&lt;/span&gt;]);
...
&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
  ...
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;List.Item&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Friend #1&amp;#39;&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;...&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;onLongPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;openHeader&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Friend #1&amp;#39;&lt;/span&gt;)}
  /&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And now I can use the &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;close&lt;/code&gt; props in &lt;code&gt;&amp;lt;ContextualActionBar&amp;gt;&lt;/code&gt; as
follows:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;./components/ContextualActionBar.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IContextualActionBarProps&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;;
  &lt;span style=&#34;color:#a6e22e&#34;&gt;close&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt;;
}
...
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
      ...
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Action&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;icon&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;close&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;close&lt;/span&gt;} /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Appbar.Content&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;title&lt;/span&gt;} /&amp;gt;
      ...
  );
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, I have a functional, Material Design-inspired Contextual Action Bar,
utilizing react-native-paper and react-navigation, which looks like the
following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.dropbox.com/s/fnotff7jas5bdlb/muicba.png?raw=1&#34; alt=&#34;Contextual Action Bar, activates when the user long presses an item&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;theming&#34;&gt;Theming&lt;/h2&gt;
&lt;p&gt;The last thing I want to do is theme my app so I can change the primary
color, secondary color, text colors, etc.&lt;/p&gt;
&lt;p&gt;Theming is a little tricky because both react-navigation and
react-native-paper have their own &lt;code&gt;ThemeProvider&lt;/code&gt; components, and they can
easily conflict with each other. Fortunately, there&amp;rsquo;s a great guide available
on 
&lt;a href=&#34;https://callstack.github.io/react-native-paper/theming-with-react-navigation.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;how to theme an app which uses both react-native-paper and react-navigation&lt;/a&gt;.
If you follow this, you should be all set to go.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll add in a little extra help for those who use Typescript and would run
into esoteric errors trying to follow the above guide.&lt;/p&gt;
&lt;p&gt;First, I’ll create a theme file which looks like the following. A few things
to note are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The return type of &lt;code&gt;combineThemes&lt;/code&gt; encompasses both &lt;code&gt;ReactNavigationTheme&lt;/code&gt;
and &lt;code&gt;ReactNativePaper.Theme&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;I changed the &lt;code&gt;primary&lt;/code&gt; and &lt;code&gt;accent&lt;/code&gt; colors, which will affect the CAB and
FAB respectively&lt;/li&gt;
&lt;li&gt;I added a new color to the theme called &lt;code&gt;animationColor&lt;/code&gt;. If you don&amp;rsquo;t want
to add a new color, you don&amp;rsquo;t need to declare the global namespace&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;theme.ts&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DarkTheme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationDarkTheme&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DefaultTheme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationDefaultTheme&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt;,
} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;ColorSchemeName&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DarkTheme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;PaperDarkTheme&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;DefaultTheme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;PaperDefaultTheme&lt;/span&gt;,
} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-paper&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;declare&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;global&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;namespace&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ReactNativePaper&lt;/span&gt; {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ThemeColors&lt;/span&gt; {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;animationColor&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt;;
    }
    &lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt; {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;statusBar&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;light&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dark&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;auto&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;inverted&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;undefined&lt;/span&gt;;
    }
  }
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ReactNavigationTheme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;statusBar&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;light&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dark&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;auto&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;inverted&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;undefined&lt;/span&gt;;
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;combineThemes&lt;/span&gt;(
  &lt;span style=&#34;color:#a6e22e&#34;&gt;themeType&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;ColorSchemeName&lt;/span&gt;
)&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ReactNativePaper&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ReactNavigationTheme&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;CombinedDefaultTheme&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;ReactNativePaper.Theme&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
    ...&lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationDefaultTheme&lt;/span&gt;,
    ...&lt;span style=&#34;color:#a6e22e&#34;&gt;PaperDefaultTheme&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;statusBar&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dark&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;colors&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
      ...&lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationDefaultTheme&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;colors&lt;/span&gt;,
      ...&lt;span style=&#34;color:#a6e22e&#34;&gt;PaperDefaultTheme&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;colors&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;animationColor&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#2922ff&amp;#39;&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;primary&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#079c20&amp;#39;&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;accent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#2922ff&amp;#39;&lt;/span&gt;,
    },
  };
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;CombinedDarkTheme&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;ReactNativePaper.Theme&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
    ...&lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationDarkTheme&lt;/span&gt;,
    ...&lt;span style=&#34;color:#a6e22e&#34;&gt;PaperDarkTheme&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;mode&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;adaptive&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;statusBar&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;light&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;colors&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
      ...&lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationDarkTheme&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;colors&lt;/span&gt;,
      ...&lt;span style=&#34;color:#a6e22e&#34;&gt;PaperDarkTheme&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;colors&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;animationColor&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#6262ff&amp;#39;&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;primary&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#079c20&amp;#39;&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;accent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#2922ff&amp;#39;&lt;/span&gt;,
    },
  };

  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;themeType&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dark&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;CombinedDarkTheme&lt;/span&gt; : &lt;span style=&#34;color:#66d9ef&#34;&gt;CombinedDefaultTheme&lt;/span&gt;;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, back in &lt;code&gt;App.tsx&lt;/code&gt; I’ll add my theme to both the react-native-paper
&lt;code&gt;Provider&lt;/code&gt; component and the &lt;code&gt;NavigationContainer&lt;/code&gt; component from
react-navigation as follows:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;App.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;useColorScheme&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;NavigationContainer&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;@react-navigation/native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;combineThemes&lt;/span&gt;} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./theme&amp;#39;&lt;/span&gt;;
...
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;colorScheme&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useColorScheme&lt;/span&gt;() &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;light&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dark&amp;#39;&lt;/span&gt;;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;theme&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;combineThemes&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;colorScheme&lt;/span&gt;);
  ...
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Provider&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;theme&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;theme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ReactNativePaper&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;NavigationContainer&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;theme&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;theme&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Theme&lt;/span&gt;}&amp;gt;
      &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;NavigationContainer&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Provider&lt;/span&gt;&amp;gt;
  ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I am using Expo, so I additionally need to add the following in &lt;code&gt;app.json&lt;/code&gt; to
enable dark mode. You may not need to:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;userInterfaceStyle&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;automatic&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And now, a custom-themed, dark-mode-enabled, Material Design-inspired app! It
looks great!&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.dropbox.com/s/7t09lhkw5iw9se9/muil1.png?raw=1&#34; alt=&#34;Contextual Action Bar and Floating Action Button with custom colors, light theme&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.dropbox.com/s/vno192lj439kbpa/muil2.png?raw=1&#34; alt=&#34;Drawer open, showing header image, light mode&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.dropbox.com/s/b4a37ljf2rrq7kv/muid1.png?raw=1&#34; alt=&#34;Contextual Action Bar and Floating Action Button with custom colors, dark theme&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.dropbox.com/s/i9oo8cobpjt18lk/muid2.png?raw=1&#34; alt=&#34;Drawer open, showing header image, dark mode&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;If you followed along to the end with me here, then you should have your own
cross-platform app with Material Design elements from the react-native-paper
library like Drawer Navigation (with custom designs in the drawer menu),
Floating Action Buttons, and Contextual Action Bars. You should also have
theming enabled which plays nicely with both the react-native-paper and
react-navigation libraries. This setup should enable you to quickly and
stylishly build out your next mobile app with ease.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Build a Google Maps style panel overlay with scrollable inner content in React Native using rn-sliding-up-panel and react-native-maps</title>
      <link>https://www.farhansayshi.com/post/sliding-up-panel-in-react-native/</link>
      <pubDate>Sun, 03 Jan 2021 00:00:00 +0000</pubDate>
      <guid>https://www.farhansayshi.com/post/sliding-up-panel-in-react-native/</guid>
      <description>&lt;p&gt;Based on StackOverflow questions like 
&lt;a href=&#34;https://stackoverflow.com/questions/64746969/is-there-a-react-native-utility-for-drag-to-expand-panels&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Is there a React Native utility for drag-to-expand panels?&lt;/a&gt; and 
&lt;a href=&#34;https://stackoverflow.com/questions/53523595/drag-up-a-scrollview-then-continue-scroll-in-react-native&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Drag up a ScrollView then continue scroll in React Native&lt;/a&gt;, it seems like a common task for React Native developers is creating &lt;strong&gt;a draggable and expandable panel overlay for a map screen&lt;/strong&gt;, like you see below.&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/spotangels.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;p&gt;There are a few features about this kind of panel that enhance the user experience but are tricky to implement:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When the panel expands, the content in the panel acts like a typical &lt;code&gt;Scrollview&lt;/code&gt; in React Native.&lt;/li&gt;
&lt;li&gt;When the panel is collapsed, the content in the panel is no longer scrollable&lt;/li&gt;
&lt;li&gt;Dragging one&amp;rsquo;s finger down the screen when the expanded panel is shown &lt;strong&gt;only collapses the panel when it seems appropraite&lt;/strong&gt;, otherwise it scrolls down the content in the expanded panel.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With the help of an open-source package, namely 
&lt;a href=&#34;https://octopitus.github.io/rn-sliding-up-panel/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;rn-sliding-up-panel&lt;/a&gt;, you can implement this user interface quickly in React Native. Here&amp;rsquo;s how.&lt;/p&gt;
&lt;h2 id=&#34;sections----omit-in-toc---&#34;&gt;Sections &lt;!-- omit in toc --&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#setup&#34;&gt;Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#installing-and-initializing-rn-sliding-up-panel&#34;&gt;Installing and initializing &lt;code&gt;rn-sliding-up-panel&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#adding-scrollability-to-a-draggable-panel&#34;&gt;Adding scrollability to a draggable panel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;
&lt;p&gt;The panel itself only has one required dependency.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;https://octopitus.github.io/rn-sliding-up-panel/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;rn-sliding-up-panel&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;ll be using other packages to make things easier (such as 
&lt;a href=&#34;https://github.com/expo/expo&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo&lt;/a&gt; and 
&lt;a href=&#34;https://callstack.github.io/react-native-paper/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;react-native-paper&lt;/a&gt;), but none of these are necessary.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll initialize my project using 
&lt;a href=&#34;https://docs.expo.io/workflow/expo-cli/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-cli&lt;/a&gt; and adding typescript support. Feel free to use your favorite React Native command line init tool or template.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;expo init -t expo-template-blank-typescript rn-google-maps-style-draggable-panel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Into this blank project, I will add a &lt;code&gt;&amp;lt;Map&amp;gt;&lt;/code&gt; component and retrieve from it data for the currently selected marker on the map. The retrieved data for the marker will be used to fill in the &lt;code&gt;&amp;lt;MapPanel&amp;gt;&lt;/code&gt; component that is both draggable and scrollable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I will only go over how to implement the &lt;code&gt;&amp;lt;MapPanel&amp;gt;&lt;/code&gt; component in this article.&lt;/strong&gt; For right now, the &lt;code&gt;&amp;lt;MapPanel&amp;gt;&lt;/code&gt; component will have a prop &lt;code&gt;marker&lt;/code&gt; which contains all the data associated with the given marker on the map that the user has selected.&lt;/p&gt;
&lt;p&gt;So to start off with, I&amp;rsquo;ll have the following:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;App.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;StatusBar&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-status-bar&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt;, { &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Text&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Map&lt;/span&gt;, { &lt;span style=&#34;color:#a6e22e&#34;&gt;MarkerData&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./Map&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MapPanel&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./MapPanel&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App() {&lt;/span&gt;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;selectedMarker&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setSelectedMarker&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MarkerData&lt;/span&gt;);

  &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onMarkerPress&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;MarkerData&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;setSelectedMarker&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;);
  }

  &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onMapPress&lt;/span&gt;()&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;setSelectedMarker&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;);
  }

  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;StatusBar&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;auto&amp;#34;&lt;/span&gt; /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Map&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onMarkerPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;onMarkerPress&lt;/span&gt;} &lt;span style=&#34;color:#a6e22e&#34;&gt;onMapPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;onMapPress&lt;/span&gt;} /&amp;gt;
      {&lt;span style=&#34;color:#a6e22e&#34;&gt;selectedMarker&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;!==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;
        &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt;
          &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MapPanel&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;selectedMarker&lt;/span&gt;} /&amp;gt;
        &lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;
          &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;
      }
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;create&lt;/span&gt;({
  &lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;flex&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;1&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;backgroundColor&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#fff&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;alignItems&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;justifyContent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
  },
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;MapPanel.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;MarkerData&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./Map&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IMapPanelProps&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;MarkerData&lt;/span&gt;
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MapPanel&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IMapPanelProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; ({ &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt; }) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;;
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MapPanel&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next I&amp;rsquo;ll add the draggable panel and show data in that panel for each marker on the map.&lt;/p&gt;
&lt;h2 id=&#34;installing-and-initializing-rn-sliding-up-panel&#34;&gt;Installing and initializing &lt;code&gt;rn-sliding-up-panel&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Add the open-source package 
&lt;a href=&#34;https://octopitus.github.io/rn-sliding-up-panel/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;rn-sliding-up-panel&lt;/a&gt; to your project&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn add rn-sliding-up-panel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now I&amp;rsquo;ll include the &lt;code&gt;&amp;lt;SlidingUpPanel&amp;gt;&lt;/code&gt; component into &lt;code&gt;MapPanel.tsx&lt;/code&gt; and the new file will look like the following&lt;/p&gt;
&lt;p&gt;&lt;code&gt;MapPanel.tsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt;, { &lt;span style=&#34;color:#a6e22e&#34;&gt;useRef&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { 
  &lt;span style=&#34;color:#a6e22e&#34;&gt;Platform&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;StatusBar&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Animated&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;ScrollView&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;useWindowDimensions&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt;
} &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;useSafeAreaInsets&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-safe-area-context&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;SlidingUpPanel&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;rn-sliding-up-panel&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;MarkerData&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./Map&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MarkerDisplay&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./MarkerDisplay&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;PanelHandle&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;./PanelHandle&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ios&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Platform&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;OS&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;ios&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;IMapPanelProps&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;MarkerData&lt;/span&gt;
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MapPanel&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FunctionComponent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;IMapPanelProps&lt;/span&gt;&amp;gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; ({ &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt; }) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;deviceHeight&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useWindowDimensions&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;height&lt;/span&gt;;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;insets&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useSafeAreaInsets&lt;/span&gt;();
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;statusBarHeight&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;number&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ios&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;insets.bottom&lt;/span&gt; : &lt;span style=&#34;color:#66d9ef&#34;&gt;StatusBar.currentHeight&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;number&lt;/span&gt;;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;top&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;deviceHeight&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;statusBarHeight&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;bottom&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;deviceHeight&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;/&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2.8&lt;/span&gt;
  };

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;snappingPoints&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [
    &lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;top&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;bottom&lt;/span&gt;
  ];

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useRef&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;SlidingUpPanel&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;|&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;null&lt;/span&gt;&amp;gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;);
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;panelPositionVal&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Animated&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Value&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;bottom&lt;/span&gt;));

  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;SlidingUpPanel&lt;/span&gt;
      &lt;span style=&#34;color:#a6e22e&#34;&gt;ref&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt;}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;animatedValue&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;panelPositionVal&lt;/span&gt;}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;snappingPoints&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;snappingPoints&lt;/span&gt;}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;backdropOpacity&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;showBackdrop&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;height&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;deviceHeight&lt;/span&gt;}
    &amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;panelContent&lt;/span&gt;}&amp;gt;
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;PanelHandle&lt;/span&gt; /&amp;gt;
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;ScrollView&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;}&amp;gt;
          &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MarkerDisplay&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;} /&amp;gt;
        &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;ScrollView&lt;/span&gt;&amp;gt;
      &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;SlidingUpPanel&lt;/span&gt;&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;create&lt;/span&gt;({
  &lt;span style=&#34;color:#a6e22e&#34;&gt;panelContent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;flex&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;1&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;width&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;100%&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;height&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;100%&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;backgroundColor&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;white&amp;#39;&lt;/span&gt;
  }
});

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MapPanel&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    Don&amp;rsquo;t worry about &lt;code&gt;&amp;lt;PanelHandle /&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;MarkerDisplay /&amp;gt;&lt;/code&gt;. Those are just for show and don&amp;rsquo;t affect the panel functionality. If you&amp;rsquo;re really interested, all the code for this project is &lt;a href=&#34;https://github.com/kathawala/rn-google-maps-style-draggable-panel&#34;&gt;here on GitHub&lt;/a&gt;.
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now I have a draggable panel that works as follows &lt;em&gt;(note that I cannot scroll the content inside the panel yet, I&amp;rsquo;ll get to that later)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/dp-noscroll.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;p&gt;A few things to highlight about the use of &lt;code&gt;&amp;lt;SlidingUpPanel&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Because of TypeScript, our use of &lt;code&gt;useRef&lt;/code&gt; to hold a reference to a React node looks like &lt;code&gt;useRef&amp;lt;SlidingUpPanel | null&amp;gt;(null)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;top&lt;/code&gt; of &lt;code&gt;draggableRange&lt;/code&gt; needs to exclude the height of the status bar / notch for the layout to look correct.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;At this point, the panel drags just like I want it to. Next, I&amp;rsquo;ll add scrollability to it.&lt;/p&gt;
&lt;h2 id=&#34;adding-scrollability-to-a-draggable-panel&#34;&gt;Adding scrollability to a draggable panel&lt;/h2&gt;
&lt;p&gt;Adding a &lt;code&gt;&amp;lt;ScrollView&amp;gt;&lt;/code&gt; as the child of &lt;code&gt;&amp;lt;SlidingUpPanel&amp;gt;&lt;/code&gt; doesn&amp;rsquo;t &lt;em&gt;just work™&lt;/em&gt; unfortunately. This is because the finger gesture to scroll the content inside the panel is also the same finger gesture to drag the panel up and down. In essence, &lt;strong&gt;I have to figure out whether a finger swipe down means the panel should slide down or whether it means the content inside the panel should scroll down.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A confusing number of events are triggered when a finger swipes down over the panel. And these events have confusingly similar-sounding names like &lt;code&gt;onMomentumScrollBegin&lt;/code&gt;, &lt;code&gt;onMomentumDragEnd&lt;/code&gt;, and &lt;code&gt;onScrollBeginDrag&lt;/code&gt;. But the correct handlers (and state for those handlers) to implement are as follows:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setScrollEnabled&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;allowDragging&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setAllowDragging&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);
&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;atTop&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setAtTop&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);

&lt;span style=&#34;color:#75715e&#34;&gt;// fired when panel is finished being dragged up or down
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// if panel is dragged to &amp;#39;top&amp;#39; position, then we switch to scrollmode
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onMomentumDragEnd&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;((&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;number&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;top&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;) {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;setScrollEnabled&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);
    &lt;span style=&#34;color:#a6e22e&#34;&gt;setAtTop&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);
  }
}, [&lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;]);

&lt;span style=&#34;color:#75715e&#34;&gt;// fired when scroll is finished inside the panel,
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// if the content in the panel has scrolled to the very top,
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// then we allow the panel to be dragged down
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// (only if the next gesture is down, not up)
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onMomentumScrollEnd&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;((&lt;span style=&#34;color:#a6e22e&#34;&gt;event&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;NativeSyntheticEvent&lt;/span&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;NativeScrollEvent&lt;/span&gt;&amp;gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;nativeEvent&lt;/span&gt; } &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;event&lt;/span&gt;;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;nativeEvent&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;contentOffset&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;y&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;===&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;) {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;setAtTop&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);
    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;ios&lt;/span&gt;) {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;setAllowDragging&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);
    }
  }
}, []);

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;PANEL_VELOCITY&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ios&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;?&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;1&lt;/span&gt; : &lt;span style=&#34;color:#66d9ef&#34;&gt;2.3&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;hideFullScreenPanelOptions&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;SlidingUpPanelAnimationConfig&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;velocity&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;PANEL_VELOCITY&lt;/span&gt;,
  &lt;span style=&#34;color:#a6e22e&#34;&gt;toValue&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;draggableRange.bottom&lt;/span&gt;
};

&lt;span style=&#34;color:#75715e&#34;&gt;// if panel is at the top and scrolling is allowed
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// check the velocity of the drag,
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// if the velocity is downward, then we animate the panel to its bottom state
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// if the velocity is upward, we treat the drag like a scroll instead
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onDragStart&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useCallback&lt;/span&gt;((&lt;span style=&#34;color:#a6e22e&#34;&gt;_&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;number&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;gestureState&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;PanResponderGestureState&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;atTop&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;) {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;gestureState&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;vy&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;) {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;setScrollEnabled&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
      &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;ios&lt;/span&gt;) {
        &lt;span style=&#34;color:#a6e22e&#34;&gt;setAllowDragging&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;);
      }
      &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;current&lt;/span&gt;) {
        &lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;current&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;show&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;hideFullScreenPanelOptions&lt;/span&gt;);
      }
    } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;setAtTop&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
      &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;ios&lt;/span&gt;) {
        &lt;span style=&#34;color:#a6e22e&#34;&gt;setAllowDragging&lt;/span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
      }
    }
  }
}, [&lt;span style=&#34;color:#a6e22e&#34;&gt;atTop&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt;]);

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And the JSX below these changes to&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;SlidingUpPanel&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;ref&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;panelRef&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;animatedValue&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;panelPositionVal&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;draggableRange&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;snappingPoints&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;snappingPoints&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;backdropOpacity&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;showBackdrop&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;height&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;deviceHeight&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;allowDragging&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;allowDragging&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;onMomentumDragEnd&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;onMomentumDragEnd&lt;/span&gt;}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;onDragStart&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;onDragStart&lt;/span&gt;}
  &amp;gt;
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;panelContent&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;PanelHandle&lt;/span&gt; /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;ScrollView&lt;/span&gt;
        &lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;scrollEnabled&lt;/span&gt;}
        &lt;span style=&#34;color:#a6e22e&#34;&gt;showsVerticalScrollIndicator&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;}
        &lt;span style=&#34;color:#a6e22e&#34;&gt;bounces&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;}
        &lt;span style=&#34;color:#a6e22e&#34;&gt;onMomentumScrollEnd&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;onMomentumScrollEnd&lt;/span&gt;}
      &amp;gt;
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;MarkerDisplay&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;marker&lt;/span&gt;} /&amp;gt;
      &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;ScrollView&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;SlidingUpPanel&lt;/span&gt;&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The callbacks are essentially telling the panel the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When the panel is at the top and the panel&amp;rsquo;s content isn&amp;rsquo;t overflowing over the top, check the direction of the next finger gesture. &lt;strong&gt;If the next finger gesture is downwards, drag the panel to the bottom, else scroll the panel content up.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;If the panel content is overflowing over the top, then scrolling should be enabled and dragging should be disabled.&lt;/li&gt;
&lt;li&gt;If the panel is not at the top, then dragging should be enabled and scrolling should be disabled.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There are some other interesting things here to note:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I use &lt;code&gt;panel.show(...)&lt;/code&gt; because it gives control over the velocity of the panel animation. If that&amp;rsquo;s not needed, &lt;code&gt;panel.hide()&lt;/code&gt; with no arguments will achieve the same thing.&lt;/li&gt;
&lt;li&gt;iOS seems to let finger gestures be interpreted as drags before letting them be interpreted as scrolls, and Android seems to do the opposite, so I explicitly toggle dragging on and off for iOS only (I&amp;rsquo;m already toggling scrolling on and off for both platforms).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And now I have a map overlay panel that seamlessly transitions between dragging and scrolling. Check it out!&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/dp-withscroll.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;This implementation hopefully helps anyone who saw this type of component in apps like Google Maps, SpotAngels, etc. and wanted to recreate it. If you want to see the full source code, it&amp;rsquo;s all available 
&lt;a href=&#34;https://github.com/kathawala/rn-google-maps-style-draggable-panel&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;here on GitHub&lt;/a&gt;. As always, comment below or contact me with any questions or additions.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Build an NPM Package with Expo Dependencies for Expo and Plain React Native Apps</title>
      <link>https://www.farhansayshi.com/post/build-an-npm-package-with-expo-dependencies-for-expo-and-plain-react-native-projects/</link>
      <pubDate>Mon, 16 Nov 2020 00:00:00 +0000</pubDate>
      <guid>https://www.farhansayshi.com/post/build-an-npm-package-with-expo-dependencies-for-expo-and-plain-react-native-projects/</guid>
      <description>&lt;p&gt;This guide will cover how to publish a react-native-compatible package to NPM, especially in the case that your package depends on expo-* libraries (e.g. 
&lt;a href=&#34;https://docs.expo.io/versions/latest/sdk/notifications/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-notifications&lt;/a&gt; or 
&lt;a href=&#34;https://docs.expo.io/versions/v39.0.0/sdk/media-library/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-media-library&lt;/a&gt;).
These libraries can be used in plain react-native projects as well, but it&amp;rsquo;s not so clear how to include them in an NPM package so that they play nicely with both expo projects and plain react-native projects.&lt;/p&gt;
&lt;h2 id=&#34;sections----omit-in-toc---&#34;&gt;Sections &lt;!-- omit in toc --&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#things-to-remember&#34;&gt;Things to Remember&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#writing-your-package&#34;&gt;Writing your package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#building-your-package&#34;&gt;Building your package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#testing-our-package&#34;&gt;Testing our package&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#expo-project&#34;&gt;Expo project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#plain-react-native-project&#34;&gt;Plain react-native project&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#publishing&#34;&gt;Publishing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Expo&lt;/strong&gt; project includes some very powerful libraries as well as its own collection of development tools which can be used to build react-native apps faster and without needing to manage separate &lt;code&gt;android&lt;/code&gt; and &lt;code&gt;ios&lt;/code&gt; folders, as one does in a traditional react-native app.
The powerful &lt;strong&gt;expo-*&lt;/strong&gt; libraries can be used in traditional react-native apps as well as apps powered by Expo, but the process for including such libraries is different for each.&lt;/p&gt;
&lt;p&gt;This can lead to some confusion about how to package and publish NPM packages which depend on expo-* libraries.
Additionally, it&amp;rsquo;s not always clear how to make such packages work in both expo-powered apps and traditional react-native apps (these are respectively called &amp;ldquo;managed&amp;rdquo; and &amp;ldquo;bare&amp;rdquo; projects in the 
&lt;a href=&#34;https://docs.expo.io/introduction/managed-vs-bare/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Expo documentation&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;But there is a simple way to package, build, and publish modules to NPM while being able to test and ensure that these modules work with all types of react-native apps, and that&amp;rsquo;s what we&amp;rsquo;ll dive into here.&lt;/p&gt;
&lt;h2 id=&#34;things-to-remember&#34;&gt;Things to Remember&lt;/h2&gt;
&lt;p&gt;If you&amp;rsquo;ve already published NPM packages before, and you&amp;rsquo;re just wondering about the differences when expo/react-native is involved, here are some things to keep in mind:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Don&amp;rsquo;t include &lt;code&gt;react&lt;/code&gt; or &lt;code&gt;react-native&lt;/code&gt; as dependencies. Include them as &lt;strong&gt;peerDependencies&lt;/strong&gt; instead so users of your package don&amp;rsquo;t end up having two different versions of &lt;code&gt;react&lt;/code&gt; or some other important package which don&amp;rsquo;t play well together&lt;/li&gt;
&lt;li&gt;You don&amp;rsquo;t need to include &lt;code&gt;expo&lt;/code&gt; as any kind of dependency at all.&lt;/li&gt;
&lt;li&gt;If you are transpiling your module code from typescript you need &lt;code&gt;react-native-unimodules&lt;/code&gt; in your &lt;strong&gt;devDependencies&lt;/strong&gt;, &lt;em&gt;do not install&lt;/em&gt; &lt;code&gt;@unimodules/core&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Users of your package with plain react-native apps need to install &lt;code&gt;react-native-unimodules&lt;/code&gt; and follow 
&lt;a href=&#34;https://docs.expo.io/bare/installing-unimodules/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;the additional instructions&lt;/a&gt; as well. Point this out in your package&amp;rsquo;s installation instructions.&lt;/li&gt;
&lt;li&gt;Some expo-* libraries have extra installation instructions for plain react-native projects (e.g. 
&lt;a href=&#34;https://github.com/expo/expo/tree/master/packages/expo-media-library#installation-in-bare-react-native-projects&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-media-library&lt;/a&gt;). Point this out in your package&amp;rsquo;s installation instructions if so.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With that in mind, let&amp;rsquo;s begin!&lt;/p&gt;
&lt;h2 id=&#34;writing-your-package&#34;&gt;Writing your package&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;re going to make a very basic NPM package called &lt;code&gt;rn-barometer&lt;/code&gt; which exports a react-native component called &lt;code&gt;AirPressure&lt;/code&gt; that displays the current Air Pressure in Pascals as detected by the device.
This package will depend on 
&lt;a href=&#34;https://docs.expo.io/versions/latest/sdk/sensors/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-sensors&lt;/a&gt; and we&amp;rsquo;re going to make this package work on both expo-powered apps and plain react-native apps.&lt;/p&gt;
&lt;p&gt;First you need to install any needed &lt;strong&gt;devDependencies&lt;/strong&gt; and regular &lt;strong&gt;dependencies&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    Although our package needs &lt;code&gt;react&lt;/code&gt; and &lt;code&gt;react-native&lt;/code&gt; and &lt;code&gt;react-native-unimodules&lt;/code&gt; to work, they cannot be specified as regular dependencies of our package.
See &lt;a href=&#34;https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375&#34;&gt;Two Reacts Won&amp;rsquo;t Be Friends&lt;/a&gt; for more on why this is.
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn add -D typescript @types/react @types/react-native react-native-unimodules
yarn add expo-sensors
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we create our package.
The code for the package is below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;src/index.tsx&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt;, { &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;useEffect&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;Barometer&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;BarometerMeasurement&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-sensors&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Text&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;AirPressure&lt;/span&gt;()  {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;emptyMeasurement&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;BarometerMeasurement&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;pressure&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;0&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;relativeAltitude&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;0&lt;/span&gt;};
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;data&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setData&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;useState&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;emptyMeasurement&lt;/span&gt;);
  &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;subscription&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;any&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;;

  &lt;span style=&#34;color:#a6e22e&#34;&gt;useEffect&lt;/span&gt;(() &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;_subscribe&lt;/span&gt;();
    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;_unsubscribe&lt;/span&gt;;
  });

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;_subscribe&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;subscription&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Barometer&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;addListener&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;barometerData&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
      &lt;span style=&#34;color:#a6e22e&#34;&gt;setData&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;barometerData&lt;/span&gt;);
    });
  };

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;_unsubscribe&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; () &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;subscription&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;subscription&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;remove&lt;/span&gt;() &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Barometer&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;removeAllListeners&lt;/span&gt;();
    &lt;span style=&#34;color:#a6e22e&#34;&gt;subscription&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;;
  };

  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;pressure&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; } &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;data&lt;/span&gt;;

  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;Text&lt;/span&gt;&amp;gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;pressure&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt;} &lt;span style=&#34;color:#a6e22e&#34;&gt;Pa&lt;/span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;Text&lt;/span&gt;&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;create&lt;/span&gt;({
  &lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;flex&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;1&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;alignItems&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;justifyContent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
  }
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ll also need a &lt;code&gt;tsconfig.json&lt;/code&gt; and a &lt;code&gt;package.json&lt;/code&gt;.
Here are ours so far.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;tsconfig.json&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;{
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;compilerOptions&amp;#34;&lt;/span&gt;: {
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;declaration&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;esModuleInterop&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;isolatedModules&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;jsx&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;react&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;lib&amp;#34;&lt;/span&gt;: [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;es6&amp;#34;&lt;/span&gt;],
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;moduleResolution&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;node&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;strict&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;target&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;esnext&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;sourceMap&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;outDir&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;dist&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;rootDir&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;src&amp;#34;&lt;/span&gt;,
  },
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;include&amp;#34;&lt;/span&gt;: [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;src&amp;#34;&lt;/span&gt;],
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;exclude&amp;#34;&lt;/span&gt;: [
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;node_modules&amp;#34;&lt;/span&gt;
  ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;package.json&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;{
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;rn-barometer&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;version&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1.0.0&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;description&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;An AirPressure component for react-native that displays the current air pressure&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;keywords&amp;#34;&lt;/span&gt;: [
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;react-native&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;expo&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;barometer&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;air pressure&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;rn-barometer&amp;#34;&lt;/span&gt;
  ],
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;author&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Farhan Kathawala &amp;lt;farhansayshi@gmail.com&amp;gt;&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;license&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;MIT&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;devDependencies&amp;#34;&lt;/span&gt;: {
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;@types/react&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;^16.9.56&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;@types/react-native&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;^0.63.35&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;react-native-unimodules&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;^0.11.0&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;typescript&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;^4.0.5&amp;#34;&lt;/span&gt;
  },
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;peerDependencies&amp;#34;&lt;/span&gt;: {
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;react&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;*&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;react-native&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;*&amp;#34;&lt;/span&gt;
  },
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;dependencies&amp;#34;&lt;/span&gt;: {
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;expo-sensors&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;^9.1.0&amp;#34;&lt;/span&gt;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;building-your-package&#34;&gt;Building your package&lt;/h2&gt;
&lt;p&gt;Our package needs to be transpiled from typescript to javascript.&lt;/p&gt;
&lt;p&gt;For this reason we&amp;rsquo;ll add the following lines to our &lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;{
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;scripts&amp;#34;&lt;/span&gt;: {
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;build&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;tsc&amp;#34;&lt;/span&gt;,
    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;prepare&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;yarn run build&amp;#34;&lt;/span&gt;
  },
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;main&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;dist/index.js&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;types&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;dist/index.d.ts&amp;#34;&lt;/span&gt;,
  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#34;files&amp;#34;&lt;/span&gt;: [
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;dist/**/*&amp;#34;&lt;/span&gt;
  ],
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When &lt;code&gt;tsc&lt;/code&gt; runs, it will create a &lt;code&gt;dist/&lt;/code&gt; folder that contains transpiled &lt;code&gt;.js&lt;/code&gt; files.
Those are the files which will end up being used by whoever downloads our NPM package.
And so we say in our &lt;code&gt;package.json&lt;/code&gt; that the main file is &lt;code&gt;dist/index.js&lt;/code&gt; and the associated type declaration file for it is &lt;code&gt;dist/index.d.ts&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can build your package now by running the following.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn run build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;testing-our-package&#34;&gt;Testing our package&lt;/h2&gt;
&lt;p&gt;Now that our package is built, it&amp;rsquo;s time to test that it works in both Expo and plain react-native projects.&lt;/p&gt;
&lt;h3 id=&#34;expo-project&#34;&gt;Expo project&lt;/h3&gt;
&lt;p&gt;Initialize a quick expo project the following way (replace &lt;code&gt;path/to/lib&lt;/code&gt; with the full path to our &lt;code&gt;rn-barometer&lt;/code&gt; library)&lt;/p&gt;
&lt;div class=&#34;alert alert-warning&#34;&gt;
  &lt;div&gt;
    When running &lt;code&gt;yarn add&lt;/code&gt; on a local module, the whole &lt;code&gt;node_modules&lt;/code&gt; folder of the local module gets pulled in.
This means, before pulling in that local module, you might want to clear &lt;code&gt;node_modules&lt;/code&gt; in the local module and run &lt;code&gt;yarn install --production&lt;/code&gt; so that your &lt;strong&gt;devDependencies&lt;/strong&gt; (i.e. &lt;code&gt;react-native-unimodules&lt;/code&gt;) are not pulled in.
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;cd ~/
expo init expo-rn-barometer -t expo-template-blank-typescript
cd expo-rn-barometer
yarn add path/to/lib/rn-barometer
expo start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now add the &lt;code&gt;AirPressure&lt;/code&gt; component to your expo project&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;App.tsx&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;StatusBar&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-status-bar&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Text&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;AirPressure&lt;/span&gt; } &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;rn-barometer&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App() {&lt;/span&gt;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;StatusBar&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;auto&amp;#34;&lt;/span&gt; /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;AirPressure&lt;/span&gt;/&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;create&lt;/span&gt;({
  &lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;flex&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;1&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;backgroundColor&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#fff&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;alignItems&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;justifyContent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
  },
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you should be able to test the app on your device / emulator.
Eventually you should see the following:&lt;/p&gt;








  











&lt;figure id=&#34;figure-expo-app-with-barometer-reading&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/rn-barometer-screenshot.png&#34; data-caption=&#34;expo app with barometer reading&#34;&gt;


  &lt;img data-src=&#34;https://www.farhansayshi.com/media/rn-barometer-screenshot.png&#34; class=&#34;lazyload&#34; alt=&#34;&#34; width=&#34;242&#34; height=&#34;512&#34;&gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    expo app with barometer reading
  &lt;/figcaption&gt;


&lt;/figure&gt;

&lt;h3 id=&#34;plain-react-native-project&#34;&gt;Plain react-native project&lt;/h3&gt;
&lt;div class=&#34;alert alert-warning&#34;&gt;
  &lt;div&gt;
    Before anyone with a plain react-native app can use your NPM package they &lt;strong&gt;MUST&lt;/strong&gt; install &lt;code&gt;react-native-unimodules&lt;/code&gt; and go through &lt;a href=&#34;https://docs.expo.io/bare/installing-unimodules/&#34;&gt;the steps listed here&lt;/a&gt;.
Please make this clear in your package&amp;rsquo;s README
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;We&amp;rsquo;ll initialize our plain react-native app very simply&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;npx react-native init plainrnbarometer --template react-native-template-typescript
cd plainrnbarometer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, we need to install &lt;code&gt;react-native-unimodules&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn add react-native-unimodules
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we need to follow 
&lt;a href=&#34;https://docs.expo.io/bare/installing-unimodules/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;the additional installation directions here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once that is finished, we&amp;rsquo;ll have a plain react-native project which can use expo dependencies.&lt;/p&gt;
&lt;p&gt;Now just&lt;/p&gt;
&lt;div class=&#34;alert alert-warning&#34;&gt;
  &lt;div&gt;
    When running &lt;code&gt;yarn add&lt;/code&gt; on a local module, the whole &lt;code&gt;node_modules&lt;/code&gt; folder of the local module gets pulled in.
This means, before pulling in that local module, you might want to clear &lt;code&gt;node_modules&lt;/code&gt; in the local module and run &lt;code&gt;yarn install --production&lt;/code&gt; so that your &lt;strong&gt;devDependencies&lt;/strong&gt; (i.e. &lt;code&gt;react&lt;/code&gt; and &lt;code&gt;react-native&lt;/code&gt;) are not pulled in.
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn add path/to/lib/rn-barometer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add the &lt;code&gt;AirPressure&lt;/code&gt; component like before&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;App.js&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-jsx&#34; data-lang=&#34;jsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;View&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;StatusBar&lt;/span&gt;} &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; {&lt;span style=&#34;color:#a6e22e&#34;&gt;AirPressure&lt;/span&gt;} &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;rn-barometer&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; () =&amp;gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;style&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;}&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;StatusBar&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;barStyle&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;dark-content&amp;#34;&lt;/span&gt; /&amp;gt;
      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;AirPressure&lt;/span&gt; /&amp;gt;
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;View&lt;/span&gt;&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;styles&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;StyleSheet&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;create&lt;/span&gt;({
  &lt;span style=&#34;color:#a6e22e&#34;&gt;container&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
    &lt;span style=&#34;color:#a6e22e&#34;&gt;flex&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;backgroundColor&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;#fff&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;alignItems&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
    &lt;span style=&#34;color:#a6e22e&#34;&gt;justifyContent&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;center&amp;#39;&lt;/span&gt;,
  },
});

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, build the app.&lt;/p&gt;
&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    Before building your app, run &lt;code&gt;yarn react-native doctor&lt;/code&gt; and make sure you are not seeing any errors or warnings.
Often times SDK or build tool mismatches will lead to your build failing, but this command will let you know beforehand if any of your tools are out of sync or you have the wrong version of some SDK installed.
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn react-native start &amp;amp;
yarn react-native run-android
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If all went well you should see something like this&lt;/p&gt;








  











&lt;figure id=&#34;figure-plain-react-native-app-with-barometer-reading&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/rn-barometer-screenshot.png&#34; data-caption=&#34;plain react-native app with barometer reading&#34;&gt;


  &lt;img data-src=&#34;https://www.farhansayshi.com/media/rn-barometer-screenshot.png&#34; class=&#34;lazyload&#34; alt=&#34;&#34; width=&#34;242&#34; height=&#34;512&#34;&gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    plain react-native app with barometer reading
  &lt;/figcaption&gt;


&lt;/figure&gt;

&lt;h2 id=&#34;publishing&#34;&gt;Publishing&lt;/h2&gt;
&lt;p&gt;Now the fun part!&lt;/p&gt;
&lt;p&gt;Publish your package to NPM with&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;yarn publish
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And answer any prompts which arise.&lt;/p&gt;
&lt;p&gt;You may not see your package on 
&lt;a href=&#34;https://npmjs.com&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;npmjs.com&lt;/a&gt; immediately, but you can see the status of your package in the NPM registry with the following command&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;npm view expo-file-dl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s also a good idea to include a README page with your package that details the different installation process for expo-powered apps vs. plain react-native apps.
The main difference is that plain react-native apps need to install their own copy of &lt;code&gt;react-native-unimodules&lt;/code&gt; and follow its post-installation steps.
Those apps may also need to follow additional post-installation steps after adding your module if your module depends on certain expo-* libraries (e.g. &lt;code&gt;expo-media-libarary&lt;/code&gt;).&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s it!
I figured this process out while publishing a recent package to NPM, called 
&lt;a href=&#34;https://www.npmjs.com/package/expo-file-dl&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-file-dl&lt;/a&gt;, which lets you download a file to the public folders on a mobile device and shows a download-progress notification to the user.
Hope it helps out someone out there :)&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>How to Save Files to a Device Folder using Expo and React-Native</title>
      <link>https://www.farhansayshi.com/post/how-to-save-files-to-a-device-folder-using-expo-and-react-native/</link>
      <pubDate>Tue, 10 Nov 2020 00:00:00 +0000</pubDate>
      <guid>https://www.farhansayshi.com/post/how-to-save-files-to-a-device-folder-using-expo-and-react-native/</guid>
      <description>&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    tl;dr I wrote a library that takes care of this whole process with one function call. It works with both managed Expo apps and regular React Native apps, you can see a demo below and installation instructions here: &lt;a href=&#34;https://github.com/kathawala/expo-file-dl&#34;&gt;expo-file-dl&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;sections----omit-in-toc---&#34;&gt;Sections &lt;!-- omit in toc --&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#demo&#34;&gt;Demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#setup&#34;&gt;Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#downloading-the-file&#34;&gt;Downloading the file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#moving-the-file-to-a-publicly-accessible-folder&#34;&gt;Moving the file to a publicly accessible folder&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#on-ios&#34;&gt;on iOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#on-android&#34;&gt;on Android&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#conclusion&#34;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;demo&#34;&gt;Demo&lt;/h2&gt;
&lt;p&gt;This is the functionality we&amp;rsquo;re trying to achieve.
All the code for this demo is available in the 
&lt;a href=&#34;https://github.com/kathawala/expo-file-dl&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-file-dl&lt;/a&gt; and 
&lt;a href=&#34;https://github.com/kathawala/expo-file-dl-example&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-file-dl-example&lt;/a&gt; repos.&lt;/p&gt;
&lt;p&gt;&lt;video controls src=&#34;https://www.farhansayshi.com/media/efdle.mp4&#34;&gt;&lt;/video&gt;&lt;/p&gt;
&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;When looking through the plethora of Expo libraries, it&amp;rsquo;s often difficult to find exactly the ones you need.
To save a file to a folder on the device&amp;rsquo;s internal storage, one might think that the &lt;code&gt;downloadAsync&lt;/code&gt; function from &lt;code&gt;expo-file-system&lt;/code&gt; would do the trick, it even let&amp;rsquo;s you specify the name of the local file you wish to download the content to!&lt;/p&gt;
&lt;p&gt;But alas, this isn&amp;rsquo;t the full answer.
Expo apps, like most mobile apps have a file storage that&amp;rsquo;s wholly their own and difficult to access from, say, a file manager app (think Amaze File Manager) or a media library app (think Google Photos).
And it&amp;rsquo;s that inaccesible storage where &lt;code&gt;downloadAsync&lt;/code&gt; stores your files.
To save a file on a publicly accessible folder in the device&amp;rsquo;s internal storage, you need to do a bit more.&lt;/p&gt;
&lt;h2 id=&#34;setup&#34;&gt;Setup&lt;/h2&gt;
&lt;p&gt;You need to install two libraries to follow along here.
These are expo libraries, but you can use them in plain react-native apps as well.
Just be sure to follow the installation instructions for &amp;ldquo;bare&amp;rdquo; or plain react-native apps.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;expo-file-system&lt;/code&gt; (
&lt;a href=&#34;https://docs.expo.io/versions/latest/sdk/filesystem/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;docs&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;expo-media-library&lt;/code&gt; (
&lt;a href=&#34;https://docs.expo.io/versions/latest/sdk/media-library/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;docs&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After you&amp;rsquo;ve done that we can proceed.&lt;/p&gt;
&lt;h2 id=&#34;downloading-the-file&#34;&gt;Downloading the file&lt;/h2&gt;
&lt;p&gt;To download a remote file&amp;rsquo;s content to a local file on the device, here&amp;rsquo;s the code:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;FileSystem&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-file-system&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fileUri&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;string&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;FileSystem&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;documentDirectory&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;}${&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;filename&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;downloadedFile&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;FileSystem.FileSystemDownloadResult&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;FileSystem&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;downloadAsync&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;uri&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;fileUri&lt;/span&gt;);

&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;downloadedFile&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;status&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;200&lt;/span&gt;) {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;handleError&lt;/span&gt;();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A bit hidden in the 
&lt;a href=&#34;https://docs.expo.io/versions/latest/sdk/filesystem/#directories&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Expo FileSystem docs&lt;/a&gt; is this note&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Each app only has read and write access to locations under the following directories: &lt;code&gt;FileSystem.documentDirectory&lt;/code&gt; and &lt;code&gt;FileSystem.cacheDirectory&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The former is more permanent, so when creating our file path to download the remote content to, we use that one.&lt;/p&gt;
&lt;p&gt;After this code executes, we&amp;rsquo;ll have the content downloaded into a folder only our app has access to.
Next, we&amp;rsquo;ll transfer this file to a publicly accessible folder.
But it&amp;rsquo;s not as simple as &lt;code&gt;mv dir1/file1 dir2/&lt;/code&gt;!&lt;/p&gt;
&lt;h2 id=&#34;moving-the-file-to-a-publicly-accessible-folder&#34;&gt;Moving the file to a publicly accessible folder&lt;/h2&gt;
&lt;h3 id=&#34;on-ios&#34;&gt;on iOS&lt;/h3&gt;
&lt;p&gt;The process described below for Android will also work on iOS devices, &lt;em&gt;but&lt;/em&gt; it will only work if the file being downloaded is an image file (.jpg, .png, .heic, etc.)&lt;/p&gt;
&lt;p&gt;For audio files, video files, document files, you&amp;rsquo;ll need to take a different approach.&lt;/p&gt;
&lt;p&gt;The best way is to use the &lt;code&gt;expo-sharing&lt;/code&gt; library (
&lt;a href=&#34;https://docs.expo.io/versions/latest/sdk/sharing/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;docs&lt;/a&gt;), which exposes different ways of dealing with different types of files.&lt;/p&gt;
&lt;p&gt;iOS has a concept called &amp;ldquo;Universal Type Identifiers&amp;rdquo;, which are special tags attached to
files to tell the OS what can be done with said files.
So, for example, a file with a UTI of &amp;ldquo;public.video&amp;rdquo; can be opened by any video player app on iOS.
You can tag files with a UTI of your choosing. The UTI &amp;ldquo;public.item&amp;rdquo; is a generic type that tells iOS that the file is some type of file, which can be saved to the user&amp;rsquo;s filesystem. It doesn&amp;rsquo;t tell iOS that the file can be opened in any media players or anything like this, so we&amp;rsquo;ll use the &amp;ldquo;public.item&amp;rdquo; UTI to tag the file when we expose a way of dealing with the file to iOS.&lt;/p&gt;
&lt;p&gt;With all this in mind, here&amp;rsquo;s how we&amp;rsquo;ll handle non-image file downloads on iOS:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Sharing&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;expo-sharing&amp;#34;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;imageFileExts&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;jpg&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;png&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;gif&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;heic&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;webp&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;bmp&amp;#39;&lt;/span&gt;];

&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;isIos&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;imageFileExts&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;every&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;downloadedFile&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;uri&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;endsWith&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;x&lt;/span&gt;))) {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;UTI&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;public.item&amp;#39;&lt;/span&gt;;
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;shareResult&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Sharing&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;shareAsync&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;downloadedFile&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;uri&lt;/span&gt;, {&lt;span style=&#34;color:#a6e22e&#34;&gt;UTI&lt;/span&gt;});
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The above will open a prompt to the user after any non-image file has downloaded.
The prompt will ask the user what the user would like to do with the file.
At that time the user has the option to select &amp;ldquo;Save to Files&amp;rdquo;.
If this is chosen, the file will be visible in the user&amp;rsquo;s Files app.&lt;/p&gt;
&lt;p&gt;Image files on iOS can be handled the same way as all files are handled in Android below.
Remember that image files on iOS will download straight to the user&amp;rsquo;s Photo Library
and be visible in the user&amp;rsquo;s Photos app. Non-image files will download to the Files app.&lt;/p&gt;
&lt;h3 id=&#34;on-android&#34;&gt;on Android&lt;/h3&gt;
&lt;p&gt;To move a file from the app-controlled &lt;code&gt;FileSystem.documentDirectory&lt;/code&gt; to a publically accessible folder, you&amp;rsquo;ll need to do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;get &lt;code&gt;MEDIA_LIBRARY&lt;/code&gt; permissions from the user
&lt;ul&gt;
&lt;li&gt;(I&amp;rsquo;m using the &lt;code&gt;expo-permissions&lt;/code&gt; library here to make it easy, you don&amp;rsquo;t have to)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;use the &lt;code&gt;expo-media-library&lt;/code&gt; to convert the local file to an &amp;ldquo;asset&amp;rdquo;&lt;/li&gt;
&lt;li&gt;find the &amp;ldquo;album&amp;rdquo; (aka folder) where you want to transfer the &amp;ldquo;asset&amp;rdquo; to, or create the &amp;ldquo;album&amp;rdquo; if it doesn&amp;rsquo;t exist&lt;/li&gt;
&lt;li&gt;move the &amp;ldquo;asset&amp;rdquo; to the &amp;ldquo;album&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&amp;rsquo;s the code to do that&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-typescript&#34; data-lang=&#34;typescript&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Permissions&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-permissions&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MediaLibrary&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;expo-media-library&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;perm&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Permissions&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;askAsync&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;Permissions&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;MEDIA_LIBRARY&lt;/span&gt;);
&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;perm&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;status&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;granted&amp;#39;&lt;/span&gt;) {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt;;
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;try&lt;/span&gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;asset&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MediaLibrary&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;createAssetAsync&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;downloadedFile&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;uri&lt;/span&gt;);
  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;album&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MediaLibrary&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;getAlbumAsync&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Download&amp;#39;&lt;/span&gt;);
  &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;album&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;) {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MediaLibrary&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;createAlbumAsync&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Download&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;asset&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
  } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;await&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;MediaLibrary&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;addAssetsToAlbumAsync&lt;/span&gt;([&lt;span style=&#34;color:#a6e22e&#34;&gt;asset&lt;/span&gt;], &lt;span style=&#34;color:#a6e22e&#34;&gt;album&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;);
  }
} &lt;span style=&#34;color:#66d9ef&#34;&gt;catch&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;) {
  &lt;span style=&#34;color:#a6e22e&#34;&gt;handleError&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;e&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice that you need to check if the album exists before calling &lt;code&gt;addAssetsToAlbumAsync&lt;/code&gt;.
If the album doesn&amp;rsquo;t exist, you call &lt;code&gt;createAlbumAsync&lt;/code&gt; instead and pass the asset along with the name of the album to create as arguments to the function.
The album will be created and the asset will be added, no need to call &lt;code&gt;addAssetsToAlbumAsync&lt;/code&gt; after that.&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s it. Now you should see your file in the &amp;lsquo;Download&amp;rsquo; folder on the device.&lt;/p&gt;
&lt;p&gt;But this only takes care of downloading the files.
Anyone using your app won&amp;rsquo;t have any idea if the download started, if it failed, or if it&amp;rsquo;s still ongoing.
To notify app users about the download status of the file, take a look at the 
&lt;a href=&#34;https://github.com/kathawala/expo-file-dl&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;expo-file-dl&lt;/a&gt; library, which implements download status notifications as an optional feature.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Free, One-Command, Self-Hosted Commento Deployment for a Hugo Site</title>
      <link>https://www.farhansayshi.com/post/free-one-command-self-hosted-commento-deployment-for-a-hugo-site/</link>
      <pubDate>Tue, 22 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://www.farhansayshi.com/post/free-one-command-self-hosted-commento-deployment-for-a-hugo-site/</guid>
      <description>&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    tl;dr I wrote an ansible-playbook that let&amp;rsquo;s you deploy Commento, the open-source, privacy-focused comment section solution to your static site. Check out &lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook&#34;&gt;the GitHub repo&lt;/a&gt; and read the &lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook/blob/master/README.md&#34;&gt;README&lt;/a&gt; to get started.
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;sections----omit-in-toc---&#34;&gt;Sections &lt;!-- omit in toc --&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#why-use-this&#34;&gt;Why use this?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#okay-how-do-i-use-it&#34;&gt;Okay, how do I use it?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#demo&#34;&gt;Demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#i-want-to-run-this-on-a-home-server-anything-i-should-know&#34;&gt;I want to run this on a home server, anything I should know?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#acknowledgements&#34;&gt;Acknowledgements&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;
&lt;a href=&#34;https://commento.io/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Commento&lt;/a&gt; is an open-source, privacy-focused alternative to Disqus for adding comments to your static site.&lt;/p&gt;
&lt;p&gt;If you want to add this to your Hugo site, there are tutorials out there about how to set up a self-hosted version of Commento (I like 
&lt;a href=&#34;https://yktoo.solutions/blog/2019/07/28-self-hosting-commento-with-docker-compose/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;this tutorial which uses docker to make the setup easy&lt;/a&gt;). But none of them are turnkey, one-command solutions.&lt;/p&gt;
&lt;p&gt;So I wrote my own turnkey, one-command solution. You can check it out here: 
&lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;commento-ansible-playbook&lt;/a&gt; and follow the 
&lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook/blob/master/README.md&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;README&lt;/a&gt; to run it.&lt;/p&gt;
&lt;h2 id=&#34;why-use-this&#34;&gt;Why use this?&lt;/h2&gt;
&lt;p&gt;You could get a &amp;ldquo;free&amp;rdquo; account with Disqus and just paste their javascript into your site and call it a day. But then your users have to deal with annoying, targetted ads. Plus you don&amp;rsquo;t really own the service. They can shut it down or decide to start charging you any day, and you&amp;rsquo;ll be stuck.&lt;/p&gt;
&lt;p&gt;With a self-hosted service, you own it. No one can take it away from you. And 
&lt;a href=&#34;https://commento.io&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Commento&lt;/a&gt; is open-source and self-hostable. It&amp;rsquo;s also centered around privacy rather than centered around advertising.&lt;/p&gt;
&lt;p&gt;And now it&amp;rsquo;s easy to set up a self-hosted solution, too. As long as you have a Linux host running Ubuntu 20.04 or Debian 10+, you can make this work. You can even make this work on an old laptop home server because this playbook supports HTTPS over non-standard ports.&lt;/p&gt;
&lt;p&gt;Plus you save a lot of hassle. You &lt;em&gt;don&amp;rsquo;t&lt;/em&gt; need to register a domain name and fiddle with DNS to point it to a new machine. You &lt;em&gt;don&amp;rsquo;t&lt;/em&gt; need to get an SSL cert and keep it up to date. You &lt;em&gt;don&amp;rsquo;t&lt;/em&gt; need to write any &lt;code&gt;systemd&lt;/code&gt; files and link them here and there on a remote host. You &lt;em&gt;do&lt;/em&gt; get to use that saved time for other things, like making more content for your users to comment on!&lt;/p&gt;
&lt;h2 id=&#34;okay-how-do-i-use-it&#34;&gt;Okay, how do I use it?&lt;/h2&gt;
&lt;p&gt;Follow the 
&lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook/blob/master/README.md&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;README&lt;/a&gt; for detailed instructions. The simple summary is that you just need to do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get a free subdomain at 
&lt;a href=&#34;https://duckdns.org&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;DuckDNS.org&lt;/a&gt;, a free, Dynamic DNS service. (&lt;em&gt;Yes&lt;/em&gt; you have to use a subdomain from here. It&amp;rsquo;s free and easy but most importantly it allows you to get an SSL cert without having port 443 open, and that was a requirement for me)&lt;/li&gt;
&lt;li&gt;Get a machine with Ubuntu 20.04/Debian 10 on it that you can ssh into. It can be a $1.25/mo. VPS (see 
&lt;a href=&#34;https://www.chicagovps.net/services/cloud-vps&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;here&lt;/a&gt;) and everything will work just fine.&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Install ansible&lt;/a&gt; and clone this git repo: 
&lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;commento-ansible-playbook&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Input your DuckDNS subdomain, credentials for Gmail (to send password reset and other moderation emails), Akismet credentials (optional, for automated spam detection), and Linux machine ssh credentials.&lt;/li&gt;
&lt;li&gt;Run the one-command deployment &lt;code&gt;ansible-playbook full_setup.yaml --ask-become-pass&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Enjoy your new comment section.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;demo&#34;&gt;Demo&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s that simple. Don&amp;rsquo;t believe me? Check out a demo of me deploying Commento with one command to a Digital Ocean box, right after spinning it up.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.farhansayshi.com/media/demonstration.gif&#34; alt=&#34;demo of commento setup on a remote box&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;i-want-to-run-this-on-a-home-server-anything-i-should-know&#34;&gt;I want to run this on a home server, anything I should know?&lt;/h2&gt;
&lt;p&gt;I made some special decisions in this playbook to support people who want to run Commento from a machine at home. Namely both the use of a Dynamic DNS provider for domain names and the decision to procure SSL certs in a way that does not require ports 80/443 to be open helped make this a possibility.&lt;/p&gt;
&lt;p&gt;If you want to do this, a couple things to know:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If you have a dynamic IP at home (most people do), then make sure to install the DuckDNS dynamic IP client on your machine beforehand. Follow the 
&lt;a href=&#34;https://duckdns.org/install.jsp&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;installation instructions&lt;/a&gt; for the option that matches your setup (I find &amp;lsquo;linux cron&amp;rsquo; and &amp;lsquo;linux GUI&amp;rsquo; to be the easiest).&lt;/li&gt;
&lt;li&gt;You&amp;rsquo;ll need to forward some ports for your installation to work correctly. Default is port 443, but if your ISP blocks that port, you can set a different port (see the 
&lt;a href=&#34;https://github.com/kathawala/commento-ansible-playbook/blob/master/README.md&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;README&lt;/a&gt; for more details). I found 
&lt;a href=&#34;https://openmyip.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;openmyip.com&lt;/a&gt; to be the best online guide to port forwarding since it has detailed instructions for each router on the market and troubleshooting tips for each one as well.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;acknowledgements&#34;&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;A free, self-hosted comment section service you can drop into a static site in less than 15 minutes is pretty snazzy. But none of it would have been possible without these free and/or open-source solutions. If you do have a little bit to spare, consider donating to these projects:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DuckDNS &amp;ndash; 
&lt;a href=&#34;https://www.paypal.com/donate/?token=H64IP14XRMgT37GwnVZGdyf2M1cXcJQZyQq76ujn0zLAJFIBHvRWownwLStmImk0RKQhem&amp;amp;country.x=GB&amp;amp;locale.x=GB&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;PayPal&lt;/a&gt; | 
&lt;a href=&#34;https://www.patreon.com/user?u=3209735&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Patreon&lt;/a&gt; | btc:16gHnv3NTjpF5ZavMi9QYBFxUkNchdicUS&lt;/li&gt;
&lt;li&gt;Commento &amp;ndash; consider 
&lt;a href=&#34;https://commento.io/pricing&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;paying for a month or two&lt;/a&gt; of commento.io&lt;/li&gt;
&lt;li&gt;Akismet &amp;ndash; they have a 
&lt;a href=&#34;https://akismet.com/plans/#&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;name your price plan&lt;/a&gt;, consider paying for a month or two if you want to use their spam moderation&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Hiding API Keys on React Native in 10 Minutes with AWS API Gatweway</title>
      <link>https://www.farhansayshi.com/post/hiding-api-keys-on-react-native-in-10-minutes-with-api-gateway/</link>
      <pubDate>Mon, 07 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://www.farhansayshi.com/post/hiding-api-keys-on-react-native-in-10-minutes-with-api-gateway/</guid>
      <description>&lt;p&gt;The popular 
&lt;a href=&#34;https://github.com/FaridSafi/react-native-google-places-autocomplete&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;react-native-google-places-autocomplete library&lt;/a&gt; asks you to paste your third-party API keys in frontend code, which is pretty insecure. But you &lt;em&gt;can&lt;/em&gt; stay secure without wasting a whole day on a custom workaround. Here&amp;rsquo;s how.&lt;/p&gt;
&lt;h2 id=&#34;sections-----omit-in-toc---&#34;&gt;Sections  &lt;!-- omit in toc --&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&#34;#introduction&#34;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#simple-proxy-on-api-gateway-web-console&#34;&gt;Simple Proxy on API Gateway (web console)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#simple-proxy-on-api-gateway-command-line&#34;&gt;Simple Proxy on API Gateway (command line)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#testing-your-proxy&#34;&gt;Testing Your Proxy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&#34;#adding-proxy-url-to-frontend&#34;&gt;Adding Proxy URL to Frontend&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;introduction&#34;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;At 
&lt;a href=&#34;https://www.crunchbase.com/organization/passed-plates&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;work&lt;/a&gt;, I&amp;rsquo;m using Farid Safi&amp;rsquo;s excellent library 
&lt;a href=&#34;https://github.com/FaridSafi/react-native-google-places-autocomplete&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;react-native-google-places-autocomplete&lt;/a&gt; to provide a UI for results from the Google Places API. It&amp;rsquo;s clean, easy-to-use, and a joy to work with.&lt;/p&gt;
&lt;p&gt;Just one issue.&lt;/p&gt;
&lt;p&gt;The library wants your API key so it can make requests to Google on your behalf&amp;hellip; &lt;em&gt;but&lt;/em&gt; React Native&amp;rsquo;s own documentation discourages this practice.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;Never store sensitive API keys in your app code.&lt;/strong&gt;&lt;/em&gt;
Anything included in your code could be accessed in plain text by inspecting the app bundle.&lt;/p&gt;
&lt;p&gt;&amp;hellip;&lt;/p&gt;
&lt;p&gt;If you must have an API key or a secret to access some resource from your app, the most secure way to handle this would be to &lt;strong&gt;&lt;em&gt;build an orchestration layer between your app and the resource.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;ndash; 
&lt;a href=&#34;https://reactnative.dev/docs/security&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Security - React Native&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That sounds pretty daunting.
An orchestration layer?
Who has time for that?!&lt;/p&gt;
&lt;p&gt;There is a workaround though, and you can set it up in &lt;em&gt;&lt;strong&gt;minutes&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;All you gotta do is set up a proxy in 
&lt;a href=&#34;https://aws.amazon.com/api-gateway/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;AWS API Gateway&lt;/a&gt; between your app and the API.
This proxy can then inject your API keys into any request you send it and then forward that request on to the Google Places API.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s how to set it up, in two different ways: through the AWS web console, and through the command line.&lt;/p&gt;
&lt;h2 id=&#34;simple-proxy-on-api-gateway-web-console&#34;&gt;Simple Proxy on API Gateway (web console)&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Visit the 
&lt;a href=&#34;https://console.aws.amazon.com/apigateway&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;API Gateway section&lt;/a&gt; of the AWS web console&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Create API&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Build&lt;/strong&gt; underneath the &lt;em&gt;REST API&lt;/em&gt; option (&lt;em&gt;not&lt;/em&gt; the &lt;em&gt;HTTP API&lt;/em&gt; option)








  











&lt;figure id=&#34;figure-build-rest-api-button-in-aws-api-gateway-console&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_01.png&#34; data-caption=&#34;Build REST API button in AWS API Gateway console&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_01.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    Build REST API button in AWS API Gateway console
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Add the name of your API and click &lt;strong&gt;Create API&lt;/strong&gt;. Use the settings shown below








  











&lt;figure id=&#34;figure-create-api-default-options-with-name-google-places-proxy&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_02.png&#34; data-caption=&#34;Create API default options with name google-places-proxy&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_02.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    Create API default options with name google-places-proxy
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Now, you should see a dropdown in the middle of the screen titled &lt;strong&gt;Actions&lt;/strong&gt;. Click that and then select &lt;strong&gt;Create Resource&lt;/strong&gt;








  











&lt;figure id=&#34;figure-option-create-resource-in-the-dropdown-menu-titled-actions&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_03.png&#34; data-caption=&#34;Option &amp;amp;lsquo;Create Resource&amp;amp;rsquo; in the dropdown menu titled &amp;amp;lsquo;Actions&amp;amp;rsquo;&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_03.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    Option &amp;lsquo;Create Resource&amp;rsquo; in the dropdown menu titled &amp;lsquo;Actions&amp;rsquo;
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;In the newly opened &lt;em&gt;New Child Resource&lt;/em&gt; tab, check the box titled &lt;strong&gt;Configure as proxy resource&lt;/strong&gt; and then click &lt;strong&gt;Create Resource&lt;/strong&gt;








  











&lt;figure id=&#34;figure-new-child-resource-tab-with-configure-as-proxy-resource-selected&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_04.png&#34; data-caption=&#34;&amp;amp;lsquo;New Child Resource&amp;amp;rsquo; tab with &amp;amp;lsquo;Configure as proxy resource&amp;amp;rsquo; selected&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_04.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    &amp;lsquo;New Child Resource&amp;rsquo; tab with &amp;lsquo;Configure as proxy resource&amp;rsquo; selected
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;In the newly opened &lt;em&gt;/{proxy+} - ANY - Setup&lt;/em&gt; tab, select the &lt;strong&gt;HTTP Proxy&lt;/strong&gt; option, enter the Google Places API root URL with &lt;code&gt;{proxy}&lt;/code&gt; at the end (&lt;code&gt;https://maps.googleapis.com/maps/api/{proxy}&lt;/code&gt;) into the &lt;em&gt;Endpoint URL&lt;/em&gt; text box, and then click &lt;strong&gt;Save&lt;/strong&gt;








  











&lt;figure id=&#34;figure-setup-tab-with-http-proxy-option-selected-and-google-places-api-url-as-the-endpoint-url&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_05.png&#34; data-caption=&#34;&amp;amp;lsquo;Setup&amp;amp;rsquo; tab with &amp;amp;lsquo;HTTP Proxy&amp;amp;rsquo; option selected and Google Places API URL as the endpoint URL&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_05.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    &amp;lsquo;Setup&amp;rsquo; tab with &amp;lsquo;HTTP Proxy&amp;rsquo; option selected and Google Places API URL as the endpoint URL
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;In the newly opened &lt;em&gt;Method Execution&lt;/em&gt; tab, click on &lt;strong&gt;Method Request&lt;/strong&gt;








  











&lt;figure id=&#34;figure-mouse-hover-over-method-request-link&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_06.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Method Request&amp;amp;rsquo; link&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_06.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Method Request&amp;rsquo; link
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add query string&lt;/strong&gt; under the &lt;em&gt;URL Query String Parameters&lt;/em&gt; section of the &lt;em&gt;Method Request&lt;/em&gt; tab








  











&lt;figure id=&#34;figure-mouse-hover-over-add-query-strng-link&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_07.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Add query strng&amp;amp;rsquo; link&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_07.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Add query strng&amp;rsquo; link
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Add a query string parameter titled &lt;code&gt;key&lt;/code&gt;. Save by clicking on the checkmark at the right of the screen








  











&lt;figure id=&#34;figure-saving-the-query-string-parameter-key&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_08.png&#34; data-caption=&#34;saving the query string parameter &amp;amp;lsquo;key&amp;amp;rsquo;&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_08.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    saving the query string parameter &amp;lsquo;key&amp;rsquo;
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Go back one page by clicking &lt;strong&gt;Method Execution&lt;/strong&gt; at the top left








  











&lt;figure id=&#34;figure-mouse-hover-over-method-execution-link&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_09.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Method Execution&amp;amp;rsquo; link&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_09.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Method Execution&amp;rsquo; link
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;In the &lt;em&gt;Method Execution&lt;/em&gt; tab, click on &lt;strong&gt;Integration Request&lt;/strong&gt;








  











&lt;figure id=&#34;figure-mouse-hover-over-integration-request-link&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_10.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Integration Request&amp;amp;rsquo; link&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_10.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Integration Request&amp;rsquo; link
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add query string&lt;/strong&gt; under the &lt;em&gt;URL Query String Parameters&lt;/em&gt; section of the &lt;em&gt;Integration Request&lt;/em&gt; tab








  











&lt;figure id=&#34;figure-mouse-hover-over-add-query-string-link&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_11.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Add query string&amp;amp;rsquo; link&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_11.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Add query string&amp;rsquo; link
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/li&gt;
&lt;li&gt;Add a query string parameter with &lt;em&gt;&amp;ldquo;Name&amp;rdquo;&lt;/em&gt; set to &lt;code&gt;key&lt;/code&gt; and &lt;em&gt;&amp;ldquo;Mapped From&amp;rdquo;&lt;/em&gt; set to &lt;code&gt;&#39;YOUR API KEY&#39;&lt;/code&gt;. Save by clicking on the checkmark at the right of the screen.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&#34;alert alert-warning&#34;&gt;
  &lt;div&gt;
    Don&amp;rsquo;t forget the single quotes around the API key! This is needed for AWS to know that you mean for the value to be a string and not a variable
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;







  











&lt;figure id=&#34;figure-saving-the-query-string-parameter-key&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_12.png&#34; data-caption=&#34;saving the query string parameter &amp;amp;lsquo;key&amp;amp;rsquo;&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_12.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    saving the query string parameter &amp;lsquo;key&amp;rsquo;
  &lt;/figcaption&gt;


&lt;/figure&gt;

15. Go back one page by clicking &lt;strong&gt;Method Execution&lt;/strong&gt; at the top left (same as step 11), and then select &lt;strong&gt;Deploy API&lt;/strong&gt; from the &lt;em&gt;Actions&lt;/em&gt; dropdown








  











&lt;figure id=&#34;figure-mouse-hover-over-deploy-api-option-from-actions-dropdown&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_13.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Deploy API&amp;amp;rsquo; option from &amp;amp;lsquo;Actions&amp;amp;rsquo; dropdown&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_13.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Deploy API&amp;rsquo; option from &amp;lsquo;Actions&amp;rsquo; dropdown
  &lt;/figcaption&gt;


&lt;/figure&gt;

16. In the modal which opens up, select &lt;strong&gt;[New Stage]&lt;/strong&gt; for the &lt;em&gt;Deployment stage&lt;/em&gt; option. Enter a name for the &lt;em&gt;&amp;ldquo;Stage name&amp;rdquo;&lt;/em&gt; option (I used &amp;ldquo;prod&amp;rdquo;) and click &lt;strong&gt;Deploy&lt;/strong&gt;








  











&lt;figure id=&#34;figure-mouse-hover-over-deploy-with-options-for-deployment-stage-and-stage-name-filled-in&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_14.png&#34; data-caption=&#34;mouse hover over &amp;amp;lsquo;Deploy&amp;amp;rsquo; with options for &amp;amp;lsquo;Deployment stage&amp;amp;rsquo; and &amp;amp;lsquo;Stage name&amp;amp;rsquo; filled in&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_14.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over &amp;lsquo;Deploy&amp;rsquo; with options for &amp;lsquo;Deployment stage&amp;rsquo; and &amp;lsquo;Stage name&amp;rsquo; filled in
  &lt;/figcaption&gt;


&lt;/figure&gt;

17. In the newly opened &lt;em&gt;Stage Editor&lt;/em&gt; page there are lots of helpful options. I personally like to set up &lt;em&gt;Logs/Tracing&lt;/em&gt; and to &lt;em&gt;Export&lt;/em&gt; my proxy configuration, but these aren&amp;rsquo;t necessary. All you need to do is note down the &lt;em&gt;Invoke URL&lt;/em&gt; and click &lt;strong&gt;Save Changes&lt;/strong&gt; at the bottom








  











&lt;figure id=&#34;figure-mouse-hover-over-the-invoke-url-link&#34;&gt;


  &lt;a data-fancybox=&#34;&#34; href=&#34;https://www.farhansayshi.com/media/api_gateway_15.png&#34; data-caption=&#34;mouse hover over the &amp;amp;lsquo;Invoke URL&amp;amp;rsquo; link&#34;&gt;


  &lt;img src=&#34;https://www.farhansayshi.com/media/api_gateway_15.png&#34; alt=&#34;&#34;  &gt;
&lt;/a&gt;


  
  
  &lt;figcaption&gt;
    mouse hover over the &amp;lsquo;Invoke URL&amp;rsquo; link
  &lt;/figcaption&gt;


&lt;/figure&gt;
&lt;/p&gt;
&lt;h2 id=&#34;simple-proxy-on-api-gateway-command-line&#34;&gt;Simple Proxy on API Gateway (command line)&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;ve created 
&lt;a href=&#34;https://registry.terraform.io/modules/kathawala/key-forwarding-api-proxy/aws/1.0.0&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;a terraform module&lt;/a&gt; that simplifies the whole process of setting up and provisioning your proxy.
We&amp;rsquo;ll use it here.
Using &lt;code&gt;terraform&lt;/code&gt;, you can follow these steps to set up your proxy.&lt;/p&gt;
&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    Follow &lt;a href=&#34;https://learn.hashicorp.com/terraform/getting-started/install.html&#34;&gt;the official terraform installation instructions&lt;/a&gt; for your platform.
  &lt;/div&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create the following file (replace ALL_CAPS variables with their respective values)&lt;/p&gt;
&lt;p&gt;&lt;code&gt;main.tf&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-hcl&#34; data-lang=&#34;hcl&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;provider&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;aws&amp;#34;&lt;/span&gt; {
    region &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;us-east-1&amp;#34;&lt;/span&gt;
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;module&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;key_forwarding_api_proxy&amp;#34;&lt;/span&gt; {
    source            &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;kathawala/key-forwarding-api-proxy/aws&amp;#34;&lt;/span&gt;
    version           &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1.0.0&amp;#34;&lt;/span&gt;
    name              &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;PROXY_NAME&amp;#34;&lt;/span&gt;
    tags &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
       tag1 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;A&amp;#34;&lt;/span&gt;
       tag2 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;B&amp;#34;&lt;/span&gt;
    }
    url               &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;THIRD_PARTY_API_URL&amp;#34;&lt;/span&gt;
    query_param_key   &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;QUERY_PARAM&amp;#34;&lt;/span&gt;
    query_param_value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;API_KEY&amp;#34;&lt;/span&gt;
}

&lt;span style=&#34;color:#66d9ef&#34;&gt;output&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;proxy_url&amp;#34;&lt;/span&gt; {
    value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;module&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;key_forwarding_api_proxy&lt;/span&gt;.&lt;span style=&#34;color:#66d9ef&#34;&gt;url&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;EXAMPLE: If we were trying to forward requests on to the URL &lt;code&gt;https://maps.googleapis.com/maps/api/&lt;/code&gt; and we wanted to insert the query parameter &lt;code&gt;?key=d7sdauhuf3ewfwej&lt;/code&gt; into each request, our &lt;code&gt;module&lt;/code&gt; block might look as follows&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-hcl&#34; data-lang=&#34;hcl&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;module&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;key_forwarding_api_proxy&amp;#34;&lt;/span&gt; {
    source            &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;kathawala/key-forwarding-api-proxy/aws&amp;#34;&lt;/span&gt;
    version           &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1.0.0&amp;#34;&lt;/span&gt;
    name              &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;google-places-api-proxy&amp;#34;&lt;/span&gt;
    tags &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {
       env &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;staging&amp;#34;&lt;/span&gt;
       api &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Google Places API&amp;#34;&lt;/span&gt;
    }
    url               &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://maps.googleapis.com/maps/api&amp;#34;&lt;/span&gt;
    query_param_key   &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;key&amp;#34;&lt;/span&gt;
    query_param_value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;d7sdauhuf3ewfwej&amp;#34;&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run &lt;code&gt;terraform init&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run &lt;code&gt;terraform plan&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run &lt;code&gt;terraform apply&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;testing-your-proxy&#34;&gt;Testing Your Proxy&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s it! Now your proxy is all set up to forward your requests along to your third-party API.
You can test it out with a request to your API.
For example, see if you can run the following command in your terminal and get the same output.&lt;/p&gt;
&lt;div class=&#34;alert alert-note&#34;&gt;
  &lt;div&gt;
    The base of the URL (&lt;code&gt;https://r54cmjlea9.execute-api.us-east-1.amazonaws.com/prod/&lt;/code&gt;) is the output value of &lt;code&gt;proxy_url&lt;/code&gt; from when you ran &lt;code&gt;terraform apply&lt;/code&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ curl &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://r54cmjlea9.execute-api.us-east-1.amazonaws.com/prod/place/search/json?location=33.618389,72.972779&amp;amp;radius=300&amp;amp;types=post_office&amp;amp;sensor=true&amp;#34;&lt;/span&gt;
&lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;html_attributions&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;[]&lt;/span&gt;,
   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;results&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;
      &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;business_status&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;OPERATIONAL&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;geometry&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;location&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lat&amp;#34;&lt;/span&gt; : 33.61868949999999,
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lng&amp;#34;&lt;/span&gt; : 72.9731161
            &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;,
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;viewport&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;northeast&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
                  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lat&amp;#34;&lt;/span&gt; : 33.62010743029149,
                  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lng&amp;#34;&lt;/span&gt; : 72.97441303029152
               &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;,
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;southwest&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
                  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lat&amp;#34;&lt;/span&gt; : 33.61740946970849,
                  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lng&amp;#34;&lt;/span&gt; : 72.97171506970849
               &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
            &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
         &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;icon&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://maps.gstatic.com/mapfiles/place_api/icons/post_office-71.png&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ec1a7a0875e550cdb4fe4ab54bfae4051e02f8ac&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;name&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Pakistan Post&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;opening_hours&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;open_now&amp;#34;&lt;/span&gt; : false
         &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;photos&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;
            &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;height&amp;#34;&lt;/span&gt; : 4160,
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;html_attributions&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;
                  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;\u003ca href=\&amp;#34;https://maps.google.com/maps/contrib/103011710570639270239\&amp;#34;\u003eSadaf Butt\u003c/a\u003e&amp;#34;&lt;/span&gt;
               &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;,
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;photo_reference&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;CmRaAAAAjZeh9iMZ2d-NedtXCUgUW8Z5l0Bnl5m7cT65_wqG_-nuhP1RvdODnZ7v-v6JqdQlO7UfaGKCj5TGRZwjfrlnVqcKVLAQz62JQs7N1G-zNYx4ZO4hRolhgUfGN6REmsG1EhAqb
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;lSYiJdYmobBzmvhWpjAGhTewfPEdjfOOMDeozGt5G7JWjqHKw&amp;#34;&lt;/span&gt;,
               &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;width&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#ae81ff&#34;&gt;3120&lt;/span&gt;
            &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
         &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;place_id&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ChIJJSmceIyW3zgRt7kx0N0FrqE&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;plus_code&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;compound_code&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;JX9F+F6 Islamabad, Pakistan&amp;#34;&lt;/span&gt;,
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;global_code&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;8J5JJX9F+F6&amp;#34;&lt;/span&gt;
         &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;rating&amp;#34;&lt;/span&gt; : 4.5,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;reference&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;ChIJJSmceIyW3zgRt7kx0N0FrqE&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;scope&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;GOOGLE&amp;#34;&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;types&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;post_office&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;finance&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;point_of_interest&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;establishment&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;user_ratings_total&amp;#34;&lt;/span&gt; : 4,
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;vicinity&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Street 50, Islamabad&amp;#34;&lt;/span&gt;
      &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
   &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;,
   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;status&amp;#34;&lt;/span&gt; : &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;OK&amp;#34;&lt;/span&gt;
&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ve just sent a request to the Google Places API, without specifying your API key.
Congrats!&lt;/p&gt;
&lt;h2 id=&#34;adding-proxy-url-to-frontend&#34;&gt;Adding Proxy URL to Frontend&lt;/h2&gt;
&lt;p&gt;Now you just need to replace the base URL of your frontend calls to the third-party API with the &lt;em&gt;Invoke URL&lt;/em&gt; (if you used command line, &lt;code&gt;proxy_url&lt;/code&gt;) value from before.
With the library I&amp;rsquo;m using (
&lt;a href=&#34;https://github.com/FaridSafi/react-native-google-places-autocomplete&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;react-native-google-places-autocomplete&lt;/a&gt;), there&amp;rsquo;s a little bit more code that needs to be changed.&lt;/p&gt;
&lt;p&gt;Before adding the proxy URL in, if you&amp;rsquo;re using the library I am, your frontend code will look something like the following:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;googleplacesinput.jsx&lt;/code&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-jsx&#34; data-lang=&#34;jsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;Image&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;Text&lt;/span&gt; } &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native&amp;#39;&lt;/span&gt;;
&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; { &lt;span style=&#34;color:#a6e22e&#34;&gt;GooglePlacesAutocomplete&lt;/span&gt; } &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;react-native-google-places-autocomplete&amp;#39;&lt;/span&gt;;

&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;GooglePlacesInput&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; () =&amp;gt; {
  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;GooglePlacesAutocomplete&lt;/span&gt;
      &lt;span style=&#34;color:#a6e22e&#34;&gt;placeholder&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Search&amp;#39;&lt;/span&gt;
      &lt;span style=&#34;color:#a6e22e&#34;&gt;onPress&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{(&lt;span style=&#34;color:#a6e22e&#34;&gt;data&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;details&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;null&lt;/span&gt;) =&amp;gt; {
        &lt;span style=&#34;color:#75715e&#34;&gt;// details is provided when fetchDetails = true
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;        &lt;span style=&#34;color:#a6e22e&#34;&gt;console&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;log&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;data&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;details&lt;/span&gt;);
      }}
      &lt;span style=&#34;color:#a6e22e&#34;&gt;query&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{
        &lt;span style=&#34;color:#a6e22e&#34;&gt;key&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;YOUR API KEY&amp;#39;&lt;/span&gt;,
        &lt;span style=&#34;color:#a6e22e&#34;&gt;language&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;en&amp;#39;&lt;/span&gt;,
      }}
    /&amp;gt;
  );
};

&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;GooglePlacesInput&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You want to be able to make this work without specifying the &lt;code&gt;key&lt;/code&gt; prop.
Fortunately, this library has a &lt;code&gt;requestUrl&lt;/code&gt; prop which lets you specify a proxy URL instead of the original domain &lt;code&gt;https://maps.googleapis.com/maps/api&lt;/code&gt;.
You can use this prop and remove your API key from this component by changing this code:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-jsx&#34; data-lang=&#34;jsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;GooglePlacesAutocomplete&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;...&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;query&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{
      &lt;span style=&#34;color:#a6e22e&#34;&gt;key&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;YOUR API KEY&amp;#39;&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;language&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;en&amp;#39;&lt;/span&gt;,
    }}
  /&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;to this code:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-jsx&#34; data-lang=&#34;jsx&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;GooglePlacesAutocomplete&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;...&lt;/span&gt;
    &lt;span style=&#34;color:#a6e22e&#34;&gt;requestUrl&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{
      &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;YOUR PROXY URL&amp;#39;&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;useOnPlatform&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;all&amp;#39;&lt;/span&gt;
    }}
    &lt;span style=&#34;color:#a6e22e&#34;&gt;query&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{{
      &lt;span style=&#34;color:#a6e22e&#34;&gt;key&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;undefined&lt;/span&gt;,
      &lt;span style=&#34;color:#a6e22e&#34;&gt;language&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;en&amp;#39;&lt;/span&gt;,
    }}
  /&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Simply replace &lt;code&gt;YOUR PROXY URL&lt;/code&gt; with the value from &lt;em&gt;Invoke URL&lt;/em&gt; (or &lt;code&gt;proxy_url&lt;/code&gt; if you used CLI) from the proxy you created in API Gateway.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
