<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rocio Jacob</title>
    <description>The latest articles on DEV Community by Rocio Jacob (@rochijacob).</description>
    <link>https://dev.to/rochijacob</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F419762%2Fafb591bb-d4d0-41c7-998e-2a37813e2000.png</url>
      <title>DEV Community: Rocio Jacob</title>
      <link>https://dev.to/rochijacob</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rochijacob"/>
    <language>en</language>
    <item>
      <title>Getting Started with AWS Elastic Beanstalk: A Step-by-Step Guide</title>
      <dc:creator>Rocio Jacob</dc:creator>
      <pubDate>Fri, 19 May 2023 09:49:09 +0000</pubDate>
      <link>https://dev.to/muvinai/getting-started-with-aws-elastic-beanstalk-a-step-by-step-guide-4o4a</link>
      <guid>https://dev.to/muvinai/getting-started-with-aws-elastic-beanstalk-a-step-by-step-guide-4o4a</guid>
      <description>&lt;p&gt;In today's rapidly evolving world of web development, deploying and managing applications in the cloud has become a crucial aspect of every project. AWS Elastic Beanstalk simplifies the process by providing a platform-as-a-service (PaaS) solution that streamlines the deployment and management of your applications. In this tutorial, we will walk you through the step-by-step process of setting up a project in AWS Elastic Beanstalk.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Sign in to the AWS Management Console
&lt;/h3&gt;

&lt;p&gt;To begin, log in to the AWS Management Console using your AWS account credentials. If you don't have an AWS account, you can sign up for one easily on the AWS website.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Step 2: Navigate to Elastic Beanstalk
&lt;/h3&gt;

&lt;p&gt;Once you're logged in, navigate to the Elastic Beanstalk service. You can find it by searching for "Elastic Beanstalk" in the AWS Management Console search bar.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Step 3: Create a New Application
&lt;/h3&gt;

&lt;p&gt;Click on the "Create Application" button to start creating your new application. Provide a meaningful name for your application and optionally enter a description to help identify its purpose.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Step 4: Create an Environment
&lt;/h3&gt;

&lt;p&gt;After creating your application, the next step is to set up an environment where your application will run. Click on the "Create environment" button.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Configure the Environment
&lt;/h3&gt;

&lt;p&gt;Choose the environment type that suits your project, such as a Web Server Environment or a Worker Environment. Provide a unique name for your environment and specify the URL that users will access your application from.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Select the Platform
&lt;/h3&gt;

&lt;p&gt;Choose the platform that matches your project's technology stack. Elastic Beanstalk supports a wide range of platforms, including Java, Node.js, Python, Ruby, PHP, and more. Select the platform that best suits your application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Customize Additional Settings
&lt;/h3&gt;

&lt;p&gt;Take advantage of the additional settings to fine-tune your environment. Customize the platform version, database configuration, security settings, and environment variables as needed to meet your application's specific requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 8: Review and Create the Environment
&lt;/h3&gt;

&lt;p&gt;Review all the configuration details you have provided and ensure everything is correct. Once you are satisfied, click on the "Create environment" button to start the deployment process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 9: Configure Application Code Deployment
&lt;/h3&gt;

&lt;p&gt;Now that your environment is set up, you can configure the deployment of your application code. Choose the desired method: uploading a ZIP file or connecting to a code repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 10: Deploy Your Application
&lt;/h3&gt;

&lt;p&gt;With your environment and code deployment configured, you are ready to deploy your application. Elastic Beanstalk will create the necessary resources and deploy your application code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 11: Access Your Application
&lt;/h3&gt;

&lt;p&gt;Once the deployment is complete, you can access your application by visiting the URL provided in the Elastic Beanstalk environment dashboard. Congratulations! Your application is up and running in Elastic Beanstalk.&lt;/p&gt;

&lt;p&gt;AWS Elastic Beanstalk simplifies the process of deploying and managing applications in the cloud. By following the steps outlined in this tutorial, you have learned how to create an application, set up an environment, configure instance and capacity settings, customize additional configurations, and deploy your application code. Elastic Beanstalk handles the underlying infrastructure, allowing you to focus on your application development. Embrace the power of Elastic Beanstalk and enjoy the seamless experience of deploying your applications in the cloud.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>elasticbeanstalk</category>
      <category>hosting</category>
      <category>howto</category>
    </item>
    <item>
      <title>Building and distributing Vite.js projects with Amplify</title>
      <dc:creator>Rocio Jacob</dc:creator>
      <pubDate>Tue, 04 Oct 2022 14:20:09 +0000</pubDate>
      <link>https://dev.to/muvinai/building-and-distributing-vitejs-projects-with-amplify-hdd</link>
      <guid>https://dev.to/muvinai/building-and-distributing-vitejs-projects-with-amplify-hdd</guid>
      <description>&lt;p&gt;On our last project we decided to use &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;vite.js&lt;/a&gt;. We can now claim we &lt;strong&gt;LOVED IT&lt;/strong&gt;! We loved vite's speed regarding serving our file and found it extremely intuitive and right for the project.&lt;/p&gt;

&lt;p&gt;Yet development with vite implied quite a problem regarding our hosting on the web app. The fact vite is module based and has css code splitting, made the hosting of the project tough. &lt;/p&gt;

&lt;p&gt;When we first started hosting it on amplify, we had the issue that the enviroment was completely blank, and none of the page contents were fetched by the service. &lt;/p&gt;

&lt;p&gt;We fixed the initial problem by using the redirect AWS suggests for SPA's:&lt;br&gt;
&lt;code&gt;&amp;lt;/^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Beware with this redirect link as it's position on teh rewrites and redirects can affect the performance of the page.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So our rewrites and redirects page ended up looking like this:&lt;/p&gt;

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

&lt;p&gt;Then we had to adapt the build settings so that the &lt;code&gt;dist&lt;/code&gt; folder vite creates can be found by amplify:&lt;/p&gt;

&lt;p&gt;Our build file ended up looking like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
&lt;span class="na"&gt;frontend&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;phases&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;preBuild&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;npm ci&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;commands&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;npm run build --prod&lt;/span&gt;
  &lt;span class="na"&gt;artifacts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# IMPORTANT - Please verify your build output directory&lt;/span&gt;
    &lt;span class="na"&gt;baseDirectory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dist&lt;/span&gt;
    &lt;span class="na"&gt;files&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;**/*'&lt;/span&gt;
  &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;node_modules/**/*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After following this steps, we could host the webpage correctly, yet amplify still had arbitrary issues on fetching some webpages. For example redirects were not working and took us to a blank page that claimed Amplify CloudFrontURL couldn't find the page. &lt;/p&gt;

&lt;p&gt;Apparently some fractions of the code weren't being found. This is the problem that held us days, and to which we struggled to find the solution. The thing was, we had to change some things in &lt;code&gt;vite.config.js&lt;/code&gt; that were making the base of the project untraceable to amplify.&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;vite.config.js&lt;/code&gt; ended up looking like this. Adding &lt;code&gt;base: './index.html'&lt;/code&gt; was what managed to fix the mistake of arbitrary 404 we had:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;react&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@vitejs/plugin-react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;mkcert&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vite-plugin-mkcert&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;react&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nf"&gt;mkcert&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
  &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// default&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./runtimeConfig&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./runtimeConfig.browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We hope this solution helps someone struggling with the same problem. &lt;/p&gt;

</description>
      <category>vite</category>
      <category>amplify</category>
      <category>aws</category>
    </item>
    <item>
      <title>Building a React Native Filter - Part 1</title>
      <dc:creator>Rocio Jacob</dc:creator>
      <pubDate>Thu, 17 Feb 2022 18:08:39 +0000</pubDate>
      <link>https://dev.to/muvinai/building-a-react-native-filter-part-1-21j7</link>
      <guid>https://dev.to/muvinai/building-a-react-native-filter-part-1-21j7</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjxwau6dlwf85sch0wfpj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjxwau6dlwf85sch0wfpj.gif" alt="App Walkthrough"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A couple of weeks ago a client asked us to create an application that displayed all of it's stores. The app had to be built in &lt;strong&gt;React Native&lt;/strong&gt; in order to speed up development time and ensure compatibility among Android and IOS and had to include a full list of our client's stores. This list was fetched from a MongoDB collection, and came as an array of objects containing information for each store (such as location, phone number, email, coordinates). Obviously, a plain list of objects doesn't satisfy a customer, as scrolling through a 189 store list to find a specific one might be extremely painful. So with React Native (our choice to build fast compatible apps) we decided to create a filter. The filter we built included features such as &lt;strong&gt;searching, categorizing and ordering according to proximity&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;In this article, we will show you how the filter was built by using a &lt;u&gt;mock API&lt;/u&gt; to build a filter with search and categorization (in the future we will write another article to show how to handle location based objects, order them and filter them). The tutorial will not cover a step by step of the whole code, but will go through the most important parts when building it. You can find the whole code in &lt;strong&gt;this&lt;/strong&gt; &lt;a href="https://snack.expo.dev/@rochi/react-native-filter" rel="noopener noreferrer"&gt;&lt;strong&gt;Expo Snack&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You will see this is a &lt;strong&gt;front-end built filter&lt;/strong&gt;, and doesn't use backend filtering. Although backend filtering is a good option (particularly to handle long lists), it works smoothly with the data we have. &lt;strong&gt;Bear in mind&lt;/strong&gt; if you have millions of elements mapping through them will impact negatively on the app's performance. &lt;/p&gt;

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

&lt;p&gt;So, to start we will be using &lt;a href="https://www.fruityvice.com/" rel="noopener noreferrer"&gt;Fruityvice's API&lt;/a&gt; that will bring a response with an array of objects containing different information about fruits. An example for the response we get is:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"genus"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Malus"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Apple"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"family"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Rosaceae"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"order"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Rosales"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"nutritions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"carbohydrates"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;11.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"protein"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"fat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"calories"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"sugar"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;10.3&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Project Structure
&lt;/h2&gt;

&lt;p&gt;Let's get hands on it to the real code. The structure our project will take is: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A main App.js file where most of the work will happen, here we will set the main states and fetch our data. &lt;/li&gt;
&lt;li&gt;Components folder.&lt;/li&gt;
&lt;li&gt;Assets folder.&lt;/li&gt;
&lt;li&gt;Data folder in order to save the initial state some variables will have.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Fetching the API
&lt;/h2&gt;

&lt;p&gt;The first thing we should do, is fetch the API. We fetch it through a simple &lt;strong&gt;fetch function built in a useEffect&lt;/strong&gt;, meaning each time the component mounts, the API is fetched and the fruits "refresh". The response is saved as a json and we can now work with it.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.fruityvice.com/api/fruit/all&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setFruits&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  Our App.js Component
&lt;/h2&gt;

&lt;p&gt;We create a &lt;code&gt;&amp;lt;SafeAreaView /&amp;gt;&lt;/code&gt; for our App.js (so that the content we build is contained within a visible space). Inside the SafeAreaView we will have three components, the &lt;strong&gt;AppBar&lt;/strong&gt; (that will hold the modal and a logo for our app), the &lt;strong&gt;modal&lt;/strong&gt; itself, and the &lt;strong&gt;Wrapper&lt;/strong&gt; (called &lt;code&gt;&amp;lt;FruitsWrapper /&amp;gt;&lt;/code&gt;) where we will render the "card-styled" list of fruits with their information.&lt;/p&gt;

&lt;p&gt;On the App.js we'll also do two things that will help us handle the Filtering correctly. &lt;/p&gt;

&lt;p&gt;First we'll set a couple of states:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setFruits&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setFilter&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initialFilter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;intermediateFilter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIntermediateFilter&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;initialFilter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;modalVisible&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setModalVisible&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;fruits&lt;/em&gt; holds the array of objects we fetch from the API&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;filter&lt;/em&gt; filter is the real filter that will be applied when the user decides to APPLY the filter within the modal&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;intermediateFilter&lt;/em&gt; is a filter that is setted while the user interacts with the modal, once the apply button is pressed, the intermediateFilter becomes the actual filter&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;modalVisible&lt;/em&gt; will handle modal visibility &lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why the intermediateFilter?&lt;/em&gt;&lt;/strong&gt; the intermediate filter ensures the fields the user clicks while in the modal will be applied correctly. We need to save the user choices as he/she advances through the modal.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Both the intermediateFilter and the filter take up an &lt;em&gt;&lt;strong&gt;initialFilter&lt;/strong&gt;&lt;/em&gt;. What is this? The &lt;code&gt;initialFilter&lt;/code&gt; is a js written in our data folder. initialFilter is an object that hold's the initial state of the fields we are going to filter.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initialFilter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;genus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;carbohydrates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  The AppBar
&lt;/h2&gt;

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

&lt;p&gt;The App bar is extremely simple. We have a logo, and a button that when pressed will change the state of the &lt;code&gt;modalVisible&lt;/code&gt; variable to true and show us the modal. &lt;/p&gt;
&lt;h2&gt;
  
  
  Displaying the info
&lt;/h2&gt;

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

&lt;p&gt;Before we filter we want to display multiple cards containing information about the fruits so we can then sort them according to the user's choices. For this we have two components &lt;code&gt;&amp;lt;FruitsWrapper /&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;InfoCard/&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;FruitsWrapper /&amp;gt;&lt;/code&gt; is the wrapper where we map through the fruits and display them. In this Wrapper we will also have the &lt;u&gt;filtering instance&lt;/u&gt;. So as long as there no filters it will display the complete object we receive from the fetch. If there filters, we will push fruits to a new variable that will be empty. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;InfoCard/&amp;gt;&lt;/code&gt; is the UI of the card that will hold the object's info. We build only one object, and then map the fetch response and render each fruit (with it's information in the cards).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The &lt;code&gt;&amp;lt;FruitsWrapper /&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This component is &lt;strong&gt;SUPER&lt;/strong&gt; important. As the logic applied here makes the magic to display the filtered content. &lt;/p&gt;

&lt;p&gt;You can see that at the beginning of the component I declared two boolean variables: &lt;code&gt;filterFruits&lt;/code&gt; and &lt;code&gt;empty&lt;/code&gt; (empty will not be used yet, but will serve us to display that no fruits were fetched). I then set up an &lt;strong&gt;empty filterArray&lt;/strong&gt; where the fruits I filter with my modal will be pushed. After doing this I set &lt;code&gt;filterFruits&lt;/code&gt; equal to &lt;code&gt;allFruits&lt;/code&gt;, the later one being the whole fruit array we brought on the first place. The following logic is key to filtering:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filterFruits&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;filterFruits&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;filterFruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// I have two things, the filter and the fruits genus (in the array) so if I filter I only want to show the ones that match the genus&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;genus&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;genus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;genus&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;filterArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filterArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;filterFruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;filterArray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;filterFruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
  &lt;span class="nx"&gt;empty&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The filtering happens if &lt;code&gt;filterFruits&lt;/code&gt; (before known as allFruits) is &lt;strong&gt;not undefined&lt;/strong&gt; (meaning it has some content) and the &lt;strong&gt;type of this is an object&lt;/strong&gt;. What we do is map through each fruit, if it &lt;u&gt;doesn't match&lt;/u&gt; the parameters we want it to, we &lt;strong&gt;return&lt;/strong&gt;, else we &lt;strong&gt;push it&lt;/strong&gt; to the &lt;code&gt;filterArray&lt;/code&gt;. If the filter array is bigger than 0 (meaning fruits were pushed) &lt;code&gt;filterArray&lt;/code&gt; (the one where we pushed) becomes &lt;code&gt;filterFruits&lt;/code&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Modal
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcqr48pwfdpktsco7kl5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcqr48pwfdpktsco7kl5.jpg" alt="An image of the App's modal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The modal is the most important part of this tutorial. For this we will use &lt;strong&gt;React Native's built in modal&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the application we built for the client we had two modal instances, the &lt;em&gt;filtering modal&lt;/em&gt; (that used the native modal) and an &lt;em&gt;alert modal&lt;/em&gt; (where we used &lt;a href="https://akveo.github.io/react-native-ui-kitten/" rel="noopener noreferrer"&gt;UI Kitten's&lt;/a&gt; modal). We like the native modal because it offers us the possibility of deciding how it transitions and it's easier to set it up fullscreen. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As we mentioned previously we chose to use an &lt;strong&gt;intermediate filter within the modal&lt;/strong&gt; so that the state management can be smooth, and we can access the different states (Remember that the &lt;code&gt;initalFilter&lt;/code&gt; was an object?). Yet, after the user click's the apply button, we want the &lt;code&gt;intermediateFilter&lt;/code&gt; to become the actual &lt;code&gt;filter&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A key thing we also have in this modal is the list of all the genus. Instead of mapping all the fruits and displaying the genus, in the App.js we created an array with &lt;strong&gt;all the unique genus&lt;/strong&gt; (so that we don't get them repeated). The following code creates an array of all the fruit.genus unique values:&lt;/p&gt;

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

const genusResult = allFruits.map(item =&amp;gt; item.genus)
  .filter((value, index, self) =&amp;gt; self.indexOf(value) === index)


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

&lt;/div&gt;

&lt;p&gt;We loop through this array that we built to create the radio buttons, as you will see in the &lt;code&gt;RadioButton.js&lt;/code&gt; file. This file holds custom built Radio Buttons. The good thing about this is that they are fully customizable, and give us more control over the user selection. &lt;/p&gt;

&lt;p&gt;The thing is, the user can only select one genus, and when the user selects the genus selected is saved in the intermediate filter. Once the user decides which genus he/she wants to see, he applies the filter and because of the logic applied in the &lt;code&gt;&amp;lt;FruitsWrapper /&amp;gt;&lt;/code&gt; only the fruits that have that genus will be shown. &lt;/p&gt;

&lt;h2&gt;
  
  
  Closing Remarks
&lt;/h2&gt;

&lt;p&gt;This was a quick tutorial over how to build the filter. We hope it was easy to follow and in the second part we will talk about querying filtering. &lt;/p&gt;

&lt;p&gt;Remember the full code is in our &lt;a href="https://snack.expo.dev/@rochi/react-native-filter" rel="noopener noreferrer"&gt;Expo Snack&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
  </channel>
</rss>
