<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Xavier Perez - thexap on Medium]]></title>
        <description><![CDATA[Stories by Xavier Perez - thexap on Medium]]></description>
        <link>https://medium.com/@thexap?source=rss-b52f81eaa92f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WFWR0yewQm1V9DaYEOGfHw.jpeg</url>
            <title>Stories by Xavier Perez - thexap on Medium</title>
            <link>https://medium.com/@thexap?source=rss-b52f81eaa92f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:18:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thexap/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to test drag and drop functionality with Cypress and react-dnd]]></title>
            <link>https://thexap.medium.com/how-to-test-drag-and-drop-functionality-with-cypress-and-react-dnd-9ed37fd1da8?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ed37fd1da8</guid>
            <category><![CDATA[e2e-testing]]></category>
            <category><![CDATA[cypressio]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Sat, 05 Jun 2021 00:05:42 GMT</pubDate>
            <atom:updated>2021-06-05T00:05:42.742Z</atom:updated>
            <content:encoded><![CDATA[<p>First, to search for items easily, I am using the React Testing Library plugin for Cypress.</p><p><a href="https://testing-library.com/docs/cypress-testing-library/intro/">https://testing-library.com/docs/cypress-testing-library/intro/</a></p><p>It is not needed. You can change your code and use .get</p><p>With 2 lines of code you can achieve drag and drop to test your code</p><p>To pick the first item I use the following line</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46ccda749e1853bf1755624baf4d1577/href">https://medium.com/media/46ccda749e1853bf1755624baf4d1577/href</a></iframe><p>Then to drag that item to the destination element i use the following line</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3acff85ce02b803c2f6cdd052c2532a5/href">https://medium.com/media/3acff85ce02b803c2f6cdd052c2532a5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ed37fd1da8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to export DeckGL and Map to image in React]]></title>
            <link>https://thexap.medium.com/how-to-export-deckgl-and-map-to-image-in-react-6e796e538b6f?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e796e538b6f</guid>
            <category><![CDATA[mapbox]]></category>
            <category><![CDATA[deckgl]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 18:00:05 GMT</pubDate>
            <atom:updated>2020-07-25T18:00:05.946Z</atom:updated>
            <content:encoded><![CDATA[<p>This react project shows how to do a screenshot of the current map drawn with deckGL and StaticMap (Mapbox) and then download it.</p><p>You can download as png, jpg, etc</p><p>Thanks to Javier who posted the solution in stackoverflow. <a href="https://stackoverflow.com/a/61660877/3961972">https://stackoverflow.com/a/61660877/3961972</a></p><p>I created a working example based on deckgl oficial examples.</p><p>Source code: <a href="https://github.com/xap5xap/image-export-deckgl-rect">https://github.com/xap5xap/image-export-deckgl-rect</a></p><p>Run the example:</p><ol><li><strong>Clone the project</strong></li></ol><p>git clone <a href="/service/mailto:git@github.com">git@github.com</a>:xap5xap/image-export-deckgl-rect.git</p><p><strong>2. Add your Mapbox api code on the variable:</strong></p><p>const MAPBOX_TOKEN=……</p><p><strong>3. Install dependencies</strong></p><p>npm install</p><p><strong>4. Run</strong></p><p>npm start</p><p>Cheers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e796e538b6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to load svgs as components in Next.js]]></title>
            <link>https://thexap.medium.com/how-to-load-svgs-as-components-in-next-js-20353dee6e32?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/20353dee6e32</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Thu, 09 Jul 2020 17:28:04 GMT</pubDate>
            <atom:updated>2020-07-09T17:28:04.364Z</atom:updated>
            <content:encoded><![CDATA[<p>If you ever wanted to migrate from Create React App to Next.JS you might probably run into this case.</p><p>In Create React App project you have a file that imports an svg to render as a component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ae57086772b9e0d834af3cd0ca8eef2/href">https://medium.com/media/5ae57086772b9e0d834af3cd0ca8eef2/href</a></iframe><p>In Next.JS this wont work.</p><p>In Next.JS you need to add the following package:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4c430a03d51051aa4a3b2d871e64b63/href">https://medium.com/media/d4c430a03d51051aa4a3b2d871e64b63/href</a></iframe><p>Then add <strong>.babelrc</strong> file if you don’t have it and add the plugins line:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1308c11f08dcc5efc5f88b193821f7e0/href">https://medium.com/media/1308c11f08dcc5efc5f88b193821f7e0/href</a></iframe><p>Ready.</p><p>Now change the import to:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c96476272a150f40462fbc9db7b06296/href">https://medium.com/media/c96476272a150f40462fbc9db7b06296/href</a></iframe><p><strong>Typescript</strong></p><p>If you are using typescript you will get the following error:</p><p><strong>Cannot find module “../assets/images/carImage.svg”</strong></p><p>Add a folder in the root called <strong>@types</strong></p><p>In that folder add a file called <strong>index.d.ts</strong></p><p>In that file add the line</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0ec0c910566703de10d98a15bee1605/href">https://medium.com/media/b0ec0c910566703de10d98a15bee1605/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20353dee6e32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to test a formik component with React Testing Library]]></title>
            <link>https://thexap.medium.com/how-to-test-a-formik-component-with-react-testing-library-a5584fcfc03f?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5584fcfc03f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-testing-library]]></category>
            <category><![CDATA[jest]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Wed, 25 Mar 2020 22:33:54 GMT</pubDate>
            <atom:updated>2020-03-25T22:33:54.493Z</atom:updated>
            <content:encoded><![CDATA[<p>When testing a formik form component you may get this warning:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae92bb32e11e088e73782fd29502946d/href">https://medium.com/media/ae92bb32e11e088e73782fd29502946d/href</a></iframe><p>To avoid this error use React Testing Library’s <strong>wait</strong> function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d41b08715394941821fbbb40d00e6f9/href">https://medium.com/media/6d41b08715394941821fbbb40d00e6f9/href</a></iframe><p>Then call your expect assertions.</p><p>To <strong>test</strong> the a handle function <strong>has been called</strong> on <strong>submit</strong> <strong>DON’T</strong> get the Button with <strong>getByText</strong>.</p><p><strong><em>This won’t work:</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85eb8d1e31707e685ea2f106348a82a8/href">https://medium.com/media/85eb8d1e31707e685ea2f106348a82a8/href</a></iframe><p>Get the button like this: <strong>querySelector(‘button[type=”submit”]’)</strong></p><p>and use <strong>wait</strong> when clicking the button.</p><p><strong>This works:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fe73f71f8f7732b8fce9479b324d728/href">https://medium.com/media/9fe73f71f8f7732b8fce9479b324d728/href</a></iframe><p>I am using <strong>useFormik</strong> inside my component.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5584fcfc03f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use AWS Amplify Auth with redux-sagas]]></title>
            <link>https://thexap.medium.com/how-to-use-aws-amplify-auth-with-redux-sagas-43193ce33c43?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/43193ce33c43</guid>
            <category><![CDATA[amplify]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux-saga]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Sat, 27 Jul 2019 17:00:38 GMT</pubDate>
            <atom:updated>2019-07-27T17:00:38.165Z</atom:updated>
            <content:encoded><![CDATA[<p>I was getting this error when I wanted to call `Auth.signUp` from a react redux saga.</p><p><strong><em>Cannot read property ‘userPool’ of null</em></strong></p><p>The code I was using:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b05b839b9864dabaf9727d782d4c91bc/href">https://medium.com/media/b05b839b9864dabaf9727d782d4c91bc/href</a></iframe><p>After doing some research I came to the solution thanks to this post</p><p><a href="https://github.com/aws-amplify/amplify-js/issues/3703">https://github.com/aws-amplify/amplify-js/issues/3703</a></p><p><strong>SOLUTION:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eac8f77335ea44b27da647ec33da0912/href">https://medium.com/media/eac8f77335ea44b27da647ec33da0912/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43193ce33c43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Setup Bulma CSS Framework With React Under 5 Minutes]]></title>
            <link>https://thexap.medium.com/how-to-setup-bulma-css-framework-with-react-under-5-minutes-a3d8c2c33a87?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3d8c2c33a87</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bulma]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 20:48:02 GMT</pubDate>
            <atom:updated>2019-04-10T20:48:02.933Z</atom:updated>
            <content:encoded><![CDATA[<p>For my next React project I decided to use a CSS framework. Before that I was using <a href="https://www.styled-components.com/">Styled-components</a> to style my components.</p><p>I did some research and found some CSS frameworks for react like <a href="https://material-ui.com/">Material UI</a>, <a href="https://reactstrap.github.io/">React Strap</a>, <a href="https://semantic-ui.com/">Semantic UI</a>, and other “pure” CSS frameworks like <a href="https://foundation.zurb.com/sites.html">Foundation</a>, or <a href="https://bulma.io/">Bulma</a>.</p><p>I decided to try Bulma because:</p><ol><li>I found it simple based on flexbox</li><li>Customizable with SASS -&gt; this way we only import the css that we are going to use in our App and not all the css making our app size bigger.</li><li>It had nothing to do with React, so, I had total control on my components functionality.</li></ol><p>In the following example, I will show you how to setup bulma with create-react-app (now that it support SASS out of the box)</p><p>The source code for this example is in <a href="https://github.com/xap5xap/bulma-react">https://github.com/xap5xap/bulma-react</a></p><p>After you created the React app with `create-react-app` add the following dependencies:</p><pre>yarn add bulma</pre><pre>yarn add node-sass</pre><p>Now modify the file App.js with the following code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54bc153395fe960a554fad294188e08e/href">https://medium.com/media/54bc153395fe960a554fad294188e08e/href</a></iframe><p>You will see that the elements are not styled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*Els06nFKTfrzcIGciu_snQ.png" /><figcaption>Elements not styled</figcaption></figure><p>Next, add the file App.sass and copy the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d880c552c4cea4d039daa5565ea04e7b/href">https://medium.com/media/d880c552c4cea4d039daa5565ea04e7b/href</a></iframe><p>This code will style the components depending on the variables that bulma provides. Also, you can import only the styles that you will use in your project</p><p>Finally, <strong>import</strong> the sass file in the <strong>App.js</strong></p><p>import &#39;./App.sass&#39;;</p><p>Now you will see the html is styled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNcM8Qb3uL0vCoe4oC00bA.png" /><figcaption>Elements styled with bulma on a ReactJS app</figcaption></figure><p>Check <a href="https://bulma.io/documentation/">Bulma documentation</a> to see what variables you can customize and the examples.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3d8c2c33a87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Dockerize your Cucumber/Capybara tests, and make them communicate with a ReactJS app on…]]></title>
            <link>https://thexap.medium.com/how-to-dockerize-your-cucumber-capybara-tests-and-make-them-communicate-with-a-reactjs-app-on-ab2ab5386d0a?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab2ab5386d0a</guid>
            <category><![CDATA[capybara]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[cucumber]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Thu, 19 Apr 2018 21:53:46 GMT</pubDate>
            <atom:updated>2018-04-19T21:53:46.607Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Dockerize your Cucumber/Capybara tests, and make them communicate with a ReactJS app on other container</h3><p>The objective of this tutorial is to dockerize your cucumber tests and run them against a ReactJS app that is running on other container</p><h3>Table of contents</h3><ol><li>Create Dockerfile</li><li>Create docker compose file</li><li>Create Makefile</li><li>Setup Capybara configuration</li><li>Run the tests and ReactJS app</li></ol><h3>Requisites</h3><p>Have a ReactJS app created and dockerized. You can look my post on <a href="https://medium.com/@thexap/how-to-dockerize-your-reactjs-app-ad618a48ad6b">how to do this</a></p><h3>1) Create dockerfile</h3><p>We need a Ruby image and we need to install Chrome driver and google chrome in this image so that the capybara tests can be run.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c815cf386854266235005cd2816c393f/href">https://medium.com/media/c815cf386854266235005cd2816c393f/href</a></iframe><h3>2) Create docker compose file</h3><p>Here I will put the 2 services, for the ReactJS app and for the Cucumber tests.</p><p>Also, note that I am using 2 Dockerfiles in this project. One for the ReactJS app and the other for the cucumber tests</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32e216997fa57ffd89795928d61dac5f/href">https://medium.com/media/32e216997fa57ffd89795928d61dac5f/href</a></iframe><h3>3) Create Makefile</h3><p>In the makefile we make a condition to start the images, to start the react app and to start the tests</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40d4a9aca740c6a44655be7d40940f61/href">https://medium.com/media/40d4a9aca740c6a44655be7d40940f61/href</a></iframe><h3>4) Setup Capybara configuration</h3><p>The most important part of this configuration is the app_host</p><p>We have to point to the container that is running the ReactJS app. So we put the name of the image in the url of the host</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e114c898433b192a22371c985257da64/href">https://medium.com/media/e114c898433b192a22371c985257da64/href</a></iframe><h3>5) Run the Cucumber Tests and the ReactJS app</h3><p>To start the docker images run</p><pre>make start-docker-image</pre><p>To start the ReactJS app run</p><pre>make serve</pre><p>To start the Cucumber Capybara tests run. Note that the reactJS app should be started before running this command. Also you have to run this command in other terminal since the above command leaves the terminal busy</p><pre>make test-e2e</pre><p>Thanks to <a href="https://www.swtestacademy.com/docker-cucumber-capybara/">this post</a> for the explanation on how to use docker and cucumber</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab2ab5386d0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to dockerize your ReactJS app]]></title>
            <link>https://thexap.medium.com/how-to-dockerize-your-reactjs-app-ad618a48ad6b?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad618a48ad6b</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 21:47:30 GMT</pubDate>
            <atom:updated>2018-04-17T21:47:30.732Z</atom:updated>
            <content:encoded><![CDATA[<p>Create your Docker image to run a React JS app</p><h3>Table of contents</h3><ol><li>Create Dockerfile</li><li>Create docker compose file</li><li>Create Makefile</li><li>Start the app</li></ol><h3>1) Create Dockerfile</h3><p>Lets use a node 8 base image and create an app folder that will hold our source code.</p><p>We are going to be able to modify the source code files in our computer and it will automatically reflect the changes to the docker image, using the live reload functionality.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b631a820a9497b35ed17824b36a98e61/href">https://medium.com/media/b631a820a9497b35ed17824b36a98e61/href</a></iframe><h3>2) Create docker compose file</h3><p>Lest create the docker-compose.yml file.</p><p>We are using the Dockerfile that we created earlier, we are using the volume tag to reflect the files from the computer to the docker image. We are taking the current folder and using to map it with the folder created in the docker image.</p><p>Finally, we use the entrypoint so that the container doesn’t exit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d9b75b15105986a3c77327d0d1d6cf9/href">https://medium.com/media/3d9b75b15105986a3c77327d0d1d6cf9/href</a></iframe><h3>3) Create the Makefile</h3><p>Lest create a Makefile that is going to hold the commands to start, stop the image. Also, it is going to have the commands to install and start the app</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b77fdcbe99067ca270fb35afe5fa945b/href">https://medium.com/media/b77fdcbe99067ca270fb35afe5fa945b/href</a></iframe><h3>4) Start the app</h3><p>Start the docker image with</p><pre>make start-docker-image</pre><p>Start the app with</p><pre>make watch</pre><p>Open the browser and run the app. For example: localhost:3000</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad618a48ad6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to run Cucumber tests from parent folder of features folder]]></title>
            <link>https://thexap.medium.com/how-to-run-cucumber-tests-from-parent-folder-of-features-folder-369bc9251d69?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/369bc9251d69</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cucumber]]></category>
            <category><![CDATA[e2e-testing]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 22:36:13 GMT</pubDate>
            <atom:updated>2018-04-07T15:18:14.598Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to run Cucumber tests from other folder than the features folder</p><p>If you want to automate the running of the cucumber tests with for example npm or yarn scripts, then this command is going to allow you do that.</p><pre>cucumber [path-of-folder-where-is-features-folder] -r [path-of-features-folder]</pre><p>For example, in my case in the root inside the root folder I have a folder called test. Inside the test folder is the features folder.</p><p>So, in my case I run this command from the root of my project:</p><pre>cucumber test/ -r test/features</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=369bc9251d69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The complete guide to create your first mobile app with React Native and Redux Sagas — Part 1]]></title>
            <link>https://thexap.medium.com/the-complete-guide-to-create-your-first-mobile-app-with-react-native-and-redux-sagas-part-1-c9986fdbcbc7?source=rss-b52f81eaa92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9986fdbcbc7</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Xavier Perez - thexap]]></dc:creator>
            <pubDate>Thu, 05 Apr 2018 15:11:07 GMT</pubDate>
            <atom:updated>2018-04-05T15:11:07.353Z</atom:updated>
            <content:encoded><![CDATA[<h3>The complete guide to create your first mobile app with React Native and Redux Sagas — Part 1</h3><p>Learn how easily you can create a real life mobile app with React Native and Redux Sagas</p><h3>Objective</h3><ul><li>The objective of this tutorial is to create a mobile app from scratch step by step</li><li>We are going to create a Cocktail app that is going to show images of cocktails and we can navigate to other screen to see the details of that cocktail.</li><li>We will learn how to consume and fetch data from an external api. We are going to use this public api to fetch data (<a href="https://www.thecocktaildb.com/api.php">https://www.thecocktaildb.com/api.php</a>)</li><li>We will install and configure redux-sagas</li></ul><h3>The other parts</h3><h4>Part 2:</h4><ul><li>We will configure navigation</li><li>We will add a secondary screen to navigate from the main screen</li></ul><h4>Part 3:</h4><ul><li>Add animations</li></ul><h4>Part 4:</h4><ul><li>Add and configure Google admob to the app</li></ul><h4>Part 5:</h4><ul><li>How to deploy to Google play store and Apple app store</li></ul><h3>Requisites</h3><ul><li>Have react native cli installed</li><li>Some knowledge of React</li></ul><h3>Source code</h3><p><a href="https://github.com/xap5xap/mobileApp">https://github.com/xap5xap/mobileApp</a></p><h3>Final result of part 1</h3><p>This is the app that we are build in the first part.</p><p>It shows a list of cocktails and its name</p><p>Basically it has one screen that request data from an <a href="https://www.thecocktaildb.com/api/json/v1/1/filter.php?g=Cocktail_glass">external API</a> and present it in a grid list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/0*vg3Izq4HyudWR85a." /></figure><h3>Table of contents</h3><ol><li>Create React Native project</li><li>Fetch data from external api</li><li>Configure Redux Sagas</li><li>Create homescreen</li><li>Run the app</li></ol><h3>1) Create React Native project</h3><ul><li>We are going to create our project and it will be called mobileApp. You are free to name it as you want.</li><li><strong>Open the command </strong>line and type</li></ul><pre>react-native init mobileApp</pre><ul><li>Let’s confirm that the app is running without problems in the emulator.</li><li><strong>Open the terminal</strong> and change the directory to the mobileApp folder and <strong>run the following command</strong> to run the app in the emulator</li></ul><pre>react-native run-ios</pre><ul><li>The app should open in the emulator</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/0*an2tJxHPvNOmzH6o." /></figure><h3>2) Fetch data from external API</h3><p>Let’s change the folder structure in our project so that it is easy to navigate and find files.</p><ul><li>In the root lets create a <strong>new folder</strong> called <strong>App</strong></li><li>Inside the App folder lest create a new folder called <strong>Services</strong></li></ul><p>Now, create a new file that will have the code that will consume the data from the external api.</p><ul><li>In the<strong> Services folder</strong>, create a new file called<strong> Api.js</strong></li><li>Lets <strong>install</strong> a new package called <strong>apisauce</strong> (<a href="https://github.com/infinitered/apisauce">https://github.com/infinitered/apisauce</a>) that will make easy to call the external API. It is not required to use this package to fetch data from an API, but I will use that for this tutorial.</li><li>Run the following command</li></ul><pre>yarn add apisauce</pre><ul><li>Add the following code to the API.js file. Basically we are exporting a function `getGlassCocktails` that fetches glass cocktails. Here you can checkout the <a href="https://www.thecocktaildb.com/api.php">API documentation</a></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ddf285c8eacb249622c33e82c51bc2/href">https://medium.com/media/06ddf285c8eacb249622c33e82c51bc2/href</a></iframe><h3>3) Configure Redux-Saga</h3><ul><li>Install the packages</li></ul><pre>yarn add redux-saga</pre><pre>yarn add react-redux</pre><pre>yarn add redux</pre><pre>yarn add reduxsauce</pre><pre>yarn add seamless-immutable</pre><p>Lets create new folders to better structure our app</p><ul><li>Inside the App folder create the folders: <strong>Containers, Redux, Sagas, Components, Themes, Images</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/175/1*0L1mV1QHcRccPfu9bhOXxg.png" /></figure><ul><li>Inside the <strong>Redux</strong> folder create the file <strong>CreateStore.js</strong></li><li>Inside the <strong>Redux</strong> folder create the file <strong>CocktailsRedux.js</strong></li><li>Inside the <strong>Sagas</strong> folder create a file <strong>CocktailsSagas.js</strong></li><li>Inside the <strong>Sagas</strong> folder create the file i<strong>ndex.js</strong></li><li>Inside the <strong>Redux</strong> folder create the file<strong> index.js</strong></li><li><strong>Please refer to the </strong><a href="https://github.com/xap5xap/mobileApp"><strong>source code</strong></a><strong> to see the actual implementation of the files</strong></li></ul><h3>4) Create the home screen</h3><ul><li>Lets move the <strong>App.js</strong> file to the <strong>Containers</strong> folder and modify the content to setup the redux store</li><li>Inside the Containers create the file <strong>HomeScreen.js</strong></li><li>I used a package called react-native-animated-ellipsis to show when fetching data the first time</li></ul><h4>4.1) Create the CocktailRowComponent</h4><ul><li>The component is going to render the image and the name of the cocktail inside the list</li><li>Create a new file called <strong>CocktailRow.js</strong> inside the <strong>Components</strong> folder</li></ul><h3>5) Run the app</h3><ul><li>Run the app in the iOS emulator with the command</li></ul><pre>react-native run-ios</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*RFORyclMBQ_l0BVgIHRbEQ.gif" /></figure><h3>Summary</h3><ul><li>This simple add was built on 4 simple steps</li><li>Add code to fetch data from external API</li><li>Configure Redux Saga</li><li>Create the screen</li><li>Style the screen</li><li>In the future I will write the rest of the parts to make it mr functional.</li><li><strong>Please refer to the </strong><a href="https://github.com/xap5xap/mobileApp"><strong>source code</strong></a><strong> to see the actual implementation of the files</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9986fdbcbc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>