<?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: Andrew Smith</title>
    <description>The latest articles on DEV Community by Andrew Smith (@andrewsmith1996).</description>
    <link>https://dev.to/andrewsmith1996</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%2F36143%2F85ece985-fd43-4a66-9fee-ed08f3db720e.jpg</url>
      <title>DEV Community: Andrew Smith</title>
      <link>https://dev.to/andrewsmith1996</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrewsmith1996"/>
    <language>en</language>
    <item>
      <title>The trend of web performance and the rise of static-site generators, with Gatsby.js, GraphQL and React.js tutorial.</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Tue, 10 Sep 2019 08:49:17 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/the-trend-of-web-performance-and-the-rise-of-static-site-generators-with-gatsby-js-graphql-and-react-js-tutorial-1jk</link>
      <guid>https://dev.to/andrewsmith1996/the-trend-of-web-performance-and-the-rise-of-static-site-generators-with-gatsby-js-graphql-and-react-js-tutorial-1jk</guid>
      <description>&lt;h1&gt;
  
  
  The trend of web performance and the rise of static-site generators, with Gatsby.js,
&lt;/h1&gt;

&lt;p&gt;Out of all the trends in today’s age of web development, the trend of high-end web performance is the one trend that singlehandedly offers the most reward and payoff to both users and web developers alike; with everyday users now expecting websites to offer blazingly fast page speeds, minimal loading times and an engaging and satisfying user experience with absolutely zero frustration.&lt;/p&gt;

&lt;p&gt;Over the recent years we’ve seen this expectation fulfilled. As we &lt;strong&gt;&lt;em&gt;constantly&lt;/em&gt;&lt;/strong&gt; push the web to do more and more, and add more features to our applications, we begin to see a &lt;strong&gt;serious&lt;/strong&gt; drop in website performance. But with web technologies such as PWAs (progressive web apps), service workers and static site generators combatting this, and ushering out the days of long native application load times and frustrating delays, developers are able to create fast, efficient and reliable applications that offer outstanding web experiences, with little development time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The bottom line is that performance matters&lt;/strong&gt;, and Google’s consistent push on this front with its Lighthouse services for PWAs and Accelerated Mobile Pages (AMP) really show how the industry big-boys are now prioritising web performance, and how we all should too.&lt;/p&gt;

&lt;p&gt;Google even gives us the stats to back this up. For example, Pinterest increased search engine traffic and sign-ups by 15% when they reduced wait times by 40% (1), and the BBC discovered that they lost an additional 10% of users for every additional second that their website took to load (2).&lt;/p&gt;

&lt;p&gt;In particular, due to their blazingly fast page speeds, enhanced security and simple development, deployment and hosting, many web developers are turning to static site generators as a way of building their websites whilst simultaneously achieving their web performance goals.&lt;/p&gt;

&lt;h3&gt;
  
  
  So, what is a static site generator?
&lt;/h3&gt;

&lt;p&gt;A common misconception with static sites are that they are a new technology, when in fact they’ve been around for &lt;strong&gt;&lt;em&gt;years&lt;/em&gt;&lt;/strong&gt;. Static sites were the original method of web development, where vanilla HTML, CSS and JavaScript were used to build websites, featuring no front-end frameworks, libraries or plugins.&lt;/p&gt;

&lt;p&gt;Static site generators themselves focus on generating vanilla HTML, CSS and JavaScript sites as the complete output, without any links to databases or server-side processing (thus making their load speeds very fast). These static HTML files are generated by the server and are ready to be returned to the browser. With the ability for static site generators to pull data from anywhere, including a wide range of CMS, APIs and content files.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the perks of using static site generators?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Speed&lt;/strong&gt;. Due to the lack of any back-end system actually delivering the website, no database queries need to be run and no client-server requests need to be processed, and with the server always having the HTML output ready to be delivered to a user, the performance of static sites are often &lt;strong&gt;&lt;em&gt;blazingly fast&lt;/em&gt;&lt;/strong&gt;. Furthermore, many static site generators have caching features that &lt;strong&gt;&lt;em&gt;further&lt;/em&gt;&lt;/strong&gt; cut down on delays. Essentially, all the server has to do is return a file, which turns out, it’s pretty good at doing quickly…&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;. Again due to the lack of a back-end system, a static site has no database that can be attacked or exploited, there are no plugins or extensions that can be used as routes into a system and there are no areas that anyone can gain unauthorised access to. WordPress (which powers a whopping &lt;strong&gt;&lt;em&gt;34%&lt;/em&gt;&lt;/strong&gt; of websites on the internet) is &lt;strong&gt;&lt;em&gt;infamous&lt;/em&gt;&lt;/strong&gt; for being exploited and having security vulnerabilities, but with static sites there isn’t really much damage that anyone can do to a set of plain HTML files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Robust&lt;/strong&gt;. Yet another JAMstack perk of having no back-end system. Deployment and scaling of a static site is much simpler, and the application as a whole is generally more stable and robust as a server is actually able to handle a lot of traffic only requesting simple static files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ease of development&lt;/strong&gt;. Static site generators significantly ease the process of development. It’s super easy to get things up and running, with minimal setup and configuration, and once the site is written it’s often just a simple command to deploy the site.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SEO&lt;/strong&gt;. It’s often the case that web crawlers can’t read complex React.js or Vue.js applications with hundreds of components, which puts them right at the bottom of the SEO barrel. But when your content is static, and you have great page speeds and performance, then you’re sure to be well-off on the SEO front.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What are the drawbacks of using static site generators?
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Real-time applications&lt;/strong&gt;. As the site is restricted to a single set of static HTML files that are generated upon every request, there’s currently no ability for creating an application that hosts real-time data. So say goodbye to any applications that require functionality such as auto-updating news stories, live commenting, live data or any form of messaging applications.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Enter Gatsby.js
&lt;/h3&gt;

&lt;p&gt;Gatsby.js is an open source framework for generating static sites. Based on the JAMstack (&lt;a href="https://jamstack.org/"&gt;https://jamstack.org&lt;/a&gt;). Gatsby uses React.js as the front-end framework of choice and GraphQL to power its data layer; ultimately allowing Gatsby to pull data in from a range of sources (basically anywhere) including CMSs such as WordPress, Drupal and Craft CMS, simple markdown files consisting of meta data, fully fledged databases and APIs or local files.&lt;/p&gt;

&lt;p&gt;Gatsby also has a tonne of plugins for extending its functionality. Gatsby uses 2 types of plugins, &lt;strong&gt;source plugins&lt;/strong&gt; for “sourcing” data into the application, such as pulling in data from CMSs such as WordPress, and &lt;strong&gt;transformer plugins&lt;/strong&gt; which “transform” data from source plugins into some new data, such as lazy loading images.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jRGyr3nn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2AOKqQlSGyTtCOdlm_.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jRGyr3nn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2AOKqQlSGyTtCOdlm_.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  React.js
&lt;/h3&gt;

&lt;p&gt;Gatsby uses React.js for building the website’s user interfaces, it’s fast and pretty nice actually (I’m a bit of a React and React Native fanboy), and according to Stack Overflow’s most recent developer survey, is the web framework of choice for 31.3% of developers, is the most loved framework by 74.5% of developers and ranks top as the most wanted web framework.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rb3Elz-k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2AIFfX3ate97WRJ-gv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rb3Elz-k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/0%2AIFfX3ate97WRJ-gv.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GraphQL
&lt;/h3&gt;

&lt;p&gt;Gatsby uses GraphQL for its data layer. Originally created by Facebook, GraphQL will allow us to pull data into our website. GraphQL is really powerful, and yields &lt;strong&gt;&lt;em&gt;really&lt;/em&gt;&lt;/strong&gt; elegant and efficient solutions. More on GraphQL later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VHieVx78--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/0%2ATiw6euetQcRVsapn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VHieVx78--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2400/0%2ATiw6euetQcRVsapn.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Tutorial
&lt;/h2&gt;

&lt;p&gt;In this tutorial we’ll be using Gatsby.js, a popular static site generator used by companies such as AirBnB and Nike. Gatsby.js utilises React.js and GraphQL, and in this tutorial we’ll be building a simple website that displays information about Star Wars films and characters (nerd alert), and then we’ll use Gatbsy.js to output a complete static website, that generates itself during build time whenever a user visits it.&lt;/p&gt;

&lt;p&gt;The project we’ll be creating to show the power of Gatsby.js is a simple application that pulls data in from the Star Wars API (SWAPI — &lt;a href="https://github.com/graphql/swapi-graphql"&gt;https://github.com/graphql/swapi-graphql&lt;/a&gt;) and displays content on films and characters from the franchise/universe. We’ll have a simple index page listing films and characters and we’ll be using a simple card layout for displaying each piece of content on the index page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Hcr5TgLt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/5120/1%2Ak8y3PoaMbp_bzd7EsQN6wQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Hcr5TgLt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/5120/1%2Ak8y3PoaMbp_bzd7EsQN6wQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aJRio9D5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/5120/1%2AqJTw-HefvTbNghFnzOpMuA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aJRio9D5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/5120/1%2AqJTw-HefvTbNghFnzOpMuA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Gatbsy’s role here involves querying the API and building the static site at runtime (whenever anybody visits the website), resulting in an ultra-fast dynamic set of web pages that load almost instantaneously. Furthermore, when new content is added to the Star Wars API, the static site will automatically pull this new content in and regenerate itself; ultimately creating a somewhat hybrid &lt;strong&gt;dynamic-static&lt;/strong&gt; site.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 — Installing Gatsby.js
&lt;/h3&gt;

&lt;p&gt;Firstly we’ll need to install Node.js, if you’ve already done this then skip this step, if not then go to &lt;a href="https://nodejs.org/en/download/"&gt;https://nodejs.org/en/download/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Next, we’ll need to use NPM to install the Gatsby.js CLI (command line interface), this will make it easier to create and manage Gatsby projects:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g gatsby-cli
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For reference, you can see all the Gatsby commands available to us by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gatsby --help
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Gatsby come with a bunch of pre-built project configurations/starter templates that make creating Gatsby projects really simple. We’ll be using the “Hello World” start template, so to create our new Gatsby project run the &lt;strong&gt;gatsby new&lt;/strong&gt; command with the name of our project, then the starter template we’ll be using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gatsby new star-wars-app [https://github.com/gatsbyjs/gatsby-starter-hello-world](https://github.com/gatsbyjs/gatsby-starter-hello-world)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will create the basic starter project for us, so run the following commands to start developing the application:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd star-wars-app
gatsby develop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then if you head to &lt;a href="http://localhost:8000/"&gt;http://localhost:8000&lt;/a&gt; you’ll see your Gatsby project with a blank hello world template!&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2 — Creating our templates
&lt;/h3&gt;

&lt;p&gt;Open up the project in your text editor of choice, I’ll be using VS Code. Open up the &lt;strong&gt;/src&lt;/strong&gt; folder, and inside this there will be a directory called &lt;strong&gt;pages&lt;/strong&gt;. As you’ve probably guessed, here is where all content pages on the site will be held. As we’ve used a starter template, they’ll be a single &lt;strong&gt;index.js&lt;/strong&gt; file that will have a single “hello world” component message in it. Remove this, as we’ll be creating our own components which are used on the index page.&lt;/p&gt;

&lt;p&gt;It’s worth noting that Gatsby has the super cool &lt;strong&gt;createPage API&lt;/strong&gt; where you can automatically generate pages based on data, so in theory we could automatically and dynamically create individual film and character pages for all films and characters that we get back from the API. This is a &lt;strong&gt;&lt;em&gt;really powerful&lt;/em&gt;&lt;/strong&gt; feature, that really puts Gatsby at the forefront of static site generators, and when leveraged properly can result in a complete website created with minimal coding time. Pretty cool, eh? But for this tutorial we’ll just be using a single index page.&lt;/p&gt;

&lt;p&gt;Next, we’ll need to create a folder to create our components. So create a new directory at &lt;strong&gt;src&lt;/strong&gt; called &lt;strong&gt;components&lt;/strong&gt;. So your project structure should be as follows:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src
 pages
   index.js
 components
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We’ll be creating two list components, one for the list of films and one for the list of characters. Then we’ll be creating two card components, one to show basic information on each film and one to show information on each character.&lt;/p&gt;

&lt;p&gt;Both the films list and characters list components will be shown on the homepage (index.js) and then each list component will show multiple card components.&lt;/p&gt;

&lt;p&gt;Firstly, let’s create the films component by creating a filmsList.js file at src/components/films with the following React code:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Here we begin by importing our film card component that we’ll create later, as well as importing React and a scoped CSS module containing styles for our cards, which again we’ll be creating later.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from “react”
import FilmCard from ‘./filmCard.js’;
import styles from “../card.module.css”
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we’re going to use the cards list prop that will be passed through by our index.js file (we’ll get to this later) to create a new array of cards, using the .map() operator. We’ll store all our cards in a constant called “cards”, ready to inject into our &lt;/p&gt;
&lt;ul&gt;&lt;/ul&gt; element.
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const cards = this.props.films.map((film, index) =&amp;gt;
    &amp;lt;li className={styles.film__card} key={film.id}&amp;gt;
        &amp;lt;FilmCard film={film} /&amp;gt;
    &amp;lt;/li&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each new card component created in this loop creates a new FilmCard component and passes its film data (such as title, episode number, release date etc) down to it as a prop. We then return a list of cards inside an unordered list element:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return &amp;lt;ul className={styles.cards__container}&amp;gt;{ cards }&amp;lt;/ul&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, let’s create a filmCard.js file at src/components/films with the following:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Here we’re just creating a card component that will simply show the data that we’ll be returning from the API, such as the episode number, title, director and the opening crawl for that movie. Later on we’ll be coming to how we actually get that data:&lt;/p&gt;

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

&amp;lt;h1 className={styles.card__title}&amp;gt;#{this.props.film.episodeId} — {this.props.film.title}&amp;lt;/h1&amp;gt;

&amp;lt;h5 className={styles.card__subtitle}&amp;gt;Release Date: &amp;lt;span className={styles.card__copy}&amp;gt;{new Date(this.props.film.releaseDate).toLocaleDateString(“en-US”)}&amp;lt;/span&amp;gt;&amp;lt;/h5&amp;gt;

&amp;lt;h5 className={styles.card__subtitle}&amp;gt;Director: &amp;lt;span className={styles.card__copy}&amp;gt;{this.props.film.director}&amp;lt;/span&amp;gt;&amp;lt;/h5&amp;gt;

&amp;lt;h5 className={styles.card__subtitle}&amp;gt;Opening Crawl: &amp;lt;span className={styles.card__copy}&amp;gt;{this.props.film.openingCrawl}&amp;lt;/span&amp;gt;&amp;lt;/h5&amp;gt;

&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We’re following a generic reusable style theme by using the classes card_&lt;em&gt;title, card&lt;/em&gt;&lt;em&gt;subtitle, card&lt;/em&gt;_copy. Nothing too fancy.&lt;/p&gt;

&lt;p&gt;One thing worth noting is that we’re formatting the film’s release date using&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.toLocaleDateString("en-US");
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is because the API returns a JavaScript date object, and we want it to look pretty on our static site 😇.&lt;/p&gt;

&lt;p&gt;Now we’ve got our film components in, we’ll do the same for our character components. Which follow very similarly to our film components.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;And the same for characterCard.js:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Both sets of components FilmList and CharacterList, and FilmCard and CharacterCard are very similar. The List components just display a list containing multiple cards, and the Card components just show various pieces of information.&lt;/p&gt;

&lt;p&gt;It’s worth noting here that the last bit of data we’re displaying is a list of starships for that character, we’ll be getting an array down from the API so again we’re just using the .map() operator to form a new array of list elements containing just the starship’s name.&lt;/p&gt;

&lt;p&gt;The structure of the project so far should be as follows:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src
 pages
   index.js
 components
   films
     filmList.js   
     filmCard.js
   characters
     characterList.js
     characterCard.js
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next we’ll head back to the index.js file and import both the FilmList and CharacterList components at the top, so that we can view them:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Here, we’re creating our home page component, with 2 arrays of objects containing information about the data on films and characters that we’re going to show. Don’t worry, we’ll be seeing this data later when we pull it in from the SWAPI by GraphQL.&lt;/p&gt;

&lt;p&gt;Now we’ll quickly add some styling to our static site.&lt;/p&gt;

&lt;p&gt;As we’re using scoped styling, so we’ll create a file inside our components folder called &lt;strong&gt;card.module.css&lt;/strong&gt;. We’ll be using a number of styles such as title, subtitle, list and copy that we’ll reuse across both film and character cards.&lt;/p&gt;

&lt;p&gt;So add the following code styling to the file:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Again these styles aren’t massively relevant to the project, they’ll just give us something nice to look at!&lt;/p&gt;

&lt;p&gt;Also create a file called global.css at src/styles and paste in the following:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This file is a global styles file that will be used across the entire site, here we’re just adding in some basic styles such as the font family.&lt;/p&gt;

&lt;p&gt;So the card.module.css file will contain all styles relating to cards, and the global.css file will contain all styles relating to the application itself.&lt;/p&gt;

&lt;p&gt;You may wonder about the “stars” and “twinkling” div inside the index.js file… this is just to create an animation background of stars twinkling on a black sky background, very nerdy… I know. ✨&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3—Plugging in GraphQL
&lt;/h3&gt;

&lt;p&gt;So far we’ve not got any data showing in our templates. But now we’ll look into using GraphQL to pull in our data from the SWAPI.&lt;/p&gt;

&lt;p&gt;It’s worth noting however that GraphQL isn’t the only way to pull data into a Gatsby application. Another powerful feature of Gatbsy is that you can pull data from a variety of sources such as markdown files and JSON files, or you can extend Gatsby with source plugins that allow you to query data from CMSs such as WordPress and Craft CMS.&lt;/p&gt;

&lt;p&gt;First, we need to install the GraphQL NPM package for the application:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save gatsby-source-graphql
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we add the following options to our gatsby-config.js file:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;The above just allows us to call the API, and it defines what field we can access the data by (swapi).&lt;/p&gt;

&lt;p&gt;Moving back to our index.js file we need to define the actual query that we’ll be using to retrieve data from the API.&lt;/p&gt;

&lt;p&gt;The beautiful thing about GraphQL is that we can literally specify the &lt;strong&gt;&lt;em&gt;exact&lt;/em&gt;&lt;/strong&gt; field names of the information that we want. Rather than returning a massive JSON object full of values, we can specify what exactly we want. We’ll add the following code to our index.js file, which is the query that GraphQL will use to retrieve data from the API:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above GraphQL query should be quite self-explanatory. It specifies the information that we want from the SWAPI, including nested data in child objects.&lt;/p&gt;

&lt;p&gt;There’s a lot more data available to us, in fact there’s whole host of data about far more Star Wars things than films and characters and you can find the full list here: &lt;a href="https://graphiql.graphcms.com/simple/v1/swapi"&gt;https://graphiql.graphcms.com/simple/v1/swapi&lt;/a&gt; as well as test out any GraphQL queries here too. But for the purpose of this tutorial we’ll just get basic information on films and characters.&lt;/p&gt;

&lt;p&gt;You can really see the power of GraphQL here, we only request the necessary information from the API instead of returning all information about a film object. We simply just dictate what we want in a predictable and robust manner. GraphQL also has the added benefit that we can returning many resources in a simple request, so instead of completing an additional request to get information on the starships of a character (like we would in a traditional REST API), we can simply append starships onto the end of our characters query. In one simple query we can get a whole host of information from a variety of sources, rather than running multiple separate API calls #GoJamStack&lt;/p&gt;

&lt;p&gt;So, your index.js file should now look like this, with the added query:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Now we’ve got our query in, we’ll go over our index.js file from earlier and I’ll explain.

&lt;p&gt;Firstly we’re binding the data retrieved by the API to our template:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const {swapi: { allFilms, allPersons }} = this.props.data;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we’re passing these data bindings to our FilmList component:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;FilmList films={allFilms} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the CharacterList:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;CharacterList characters={allPersons} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As you’ll notice here, our earlier bindings to the allFilms and allPersons results are now being used as “films” and “characters” props down to the list components we created earlier.&lt;/p&gt;

&lt;p&gt;We’re also using the following 2 divs to show a fancy twinkling star background in light of our Star Wars theme.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div className="stars"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div className="twinkling"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now that we’re pulling in the SWAPI data using GraphQL, if you console.log() allFilms and allPersons out you should see the following JSON data in the console:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8XTOTID_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3576/1%2AijNkbJGRn91qrbO51_TCLw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8XTOTID_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3576/1%2AijNkbJGRn91qrbO51_TCLw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which means our GraphQL query to the SWAPI is successful!&lt;/p&gt;

&lt;p&gt;You’ve seen that from index.js we’re passing our film and character data through to our FilmsList and CharacterList. Below is what our FilmsList component looks like. Here we’re simply just receiving the card props from the parent component (index.js) and creating a new array of FilmCard components with it, then we’re displaying the cards inside an &lt;/p&gt;
&lt;ul&gt;&lt;/ul&gt;.


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This is the same for our CharacterList component&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In our FilmCard component we’ll just display the information we’ve pulled from the API:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And in the character card component we’ll just do the same for character related information:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now we should have a working local website that queries the SWAPI for Star Wars films and characters, passes these results into a list component, which in turn loops through all films and all characters to create card components displaying the information on said films and characters.&lt;/p&gt;

&lt;p&gt;There’s plenty of expansion that could be done to this project, as mentioned earlier there’s a whole host of other Star Wars related information that we could query for and show, and we could even look at dynamically creating pages from the API. But we’ll break off here and build a production version of our site, which would be used to generate the static pages.&lt;/p&gt;

&lt;p&gt;A full version of this project can be seen at: &lt;a href="https://github.com/andrewsmith1996/gatsby-js-star-wars-app"&gt;https://github.com/andrewsmith1996/gatsby-js-star-wars-app&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4— Building for Production
&lt;/h3&gt;

&lt;p&gt;Now that our site is complete, we’ll build it for production.&lt;/p&gt;

&lt;p&gt;First we’ll stop our development serve, and we’ll run the following command:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gatsby build
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then we can view our production site locally to double check that everything is okay:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gatsby serve
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now we have a production build of our Gatsby site, ready to go live.&lt;/p&gt;

&lt;p&gt;To prove how fast Gatsby sites really are we’ll run a Google Lighthouse audit, which will give us back some information on page speeds and performance. Google recommends using this as a way to assess the performance of PWA.&lt;/p&gt;

&lt;p&gt;Open the site in incognito mode in Google Chrome, and go over to the Audit tab and click “perform audit”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zCvMVvvS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2872/1%2A28JFlTZf0ov3bpZRkKSJZw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zCvMVvvS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2872/1%2A28JFlTZf0ov3bpZRkKSJZw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the audit has completed, you should see the following statistics about our site:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--99udlsGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3188/1%2AzyAQNiQvB5OCnB2gLHlUOg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--99udlsGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/3188/1%2AzyAQNiQvB5OCnB2gLHlUOg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above statistics really do show how well Gatsby performs and how fast it can run due to only returning static content, ultimately conforming to our trend of high-end web performance. Especially given that we’re doing API calls to an external service at runtime.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;So, we’ve created our sample application in Gatsby, and we’ve seen how powerful, fast and efficient a static site can be and how they can be created with bare minimal code and setup.&lt;/p&gt;

&lt;p&gt;We’ve seen how React can be utilised to maintain the aspect of building a single page application and how GraphQL can be a really elegant solution in terms of querying data for your application. Gatsby.js isn’t the only static site generator that’s out there, there’s Jekyll, Hugo and Gridsome (for Vue.js), which people are saying good things about. But Gatsby.js is a great choice for creating super efficient and extremely fast sites straight off the bat, and with the ability for Gabsty to be extended with plugins, the wide range of data sources that Gatsby can pull from and the ability to dynamically create pages from data with just a few lines of code using its &lt;strong&gt;createPage API&lt;/strong&gt; really set it out there as a top static site generator.&lt;/p&gt;

&lt;p&gt;Static site generators are sure to continue growing, and as the trend of ultra high-end web performance emerges with applications such as PWAs and serverless systems, and the JAMstack becomes more and more popular in the field of web development we’re going to move into a new era of ultra-fast, performance-centred, security conscious client side applications that offer a great experience for both users and developers.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;p&gt;1: &lt;a href="https://medium.com/pinterest-engineering/driving-user-growth-with-performance-improvements-cfc50dafadd7"&gt;https://medium.com/pinterest-engineering/driving-user-growth-with-performance-improvements-cfc50dafadd7&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.creativebloq.com/features/how-the-bbc-builds-websites-that-scale"&gt;2: https://www.creativebloq.com/features/how-the-bbc-builds-websites-that-scale&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gatsbyjs</category>
      <category>graphql</category>
      <category>staticsitegenerators</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to build an Geolocation Weather Forecast app in React Native in 30 minutes</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Wed, 19 Sep 2018 13:35:43 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/how-to-build-an-geolocation-weather-forecast-app-in-react-native-in-30-minutes-1kmo</link>
      <guid>https://dev.to/andrewsmith1996/how-to-build-an-geolocation-weather-forecast-app-in-react-native-in-30-minutes-1kmo</guid>
      <description>&lt;p&gt;Following on from my last guide on how to create an Image Recognition app in React Native (&lt;a href="https://dev.to/andrewsmith1996/how-to-build-an-image-recognition-app-in-react-native-m6g"&gt;https://dev.to/andrewsmith1996/how-to-build-an-image-recognition-app-in-react-native-m6g&lt;/a&gt;) I'm going to write a guide on how to build a simple Geolocation Weather Forecast app in React Native (in under 30 minutes, ofcourse)&lt;/p&gt;

&lt;p&gt;We'll be building a simple app that uses a mobile phone's Geolocation functionality to take a user's location, then pass the latitude and longitude of the location to Open Weather Map's Weather API, which will give us a 5 day weather forecast (split into 3 hour chunks) for that location.&lt;/p&gt;

&lt;p&gt;The Weather API is free, and you'll need to grab your key to use the app at &lt;a href="https://openweathermap.org/api" rel="noopener noreferrer"&gt;https://openweathermap.org/api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fi9v16xw7a8cke74irm0s.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fi9v16xw7a8cke74irm0s.png" alt="Screenshots of finished app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tutorial presumes you have NodeJS and React Native installed. If you don't then head over to &lt;a href="https://facebook.github.io/react-native/docs/getting-started.html" rel="noopener noreferrer"&gt;https://facebook.github.io/react-native/docs/getting-started.html&lt;/a&gt; to get started. It also presumes you have a basic understanding of React and NodeJS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we'll build
&lt;/h2&gt;

&lt;p&gt;We'll only actually be creating 1 extra React component here, and that's the actual card that will show each 3 hour block of weather forecast on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's begin
&lt;/h2&gt;

&lt;p&gt;Firstly, you'll need to initialise a new React Native app.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then CD into your new React Native projects directory, and run the following command to boot up the iOS simulator.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Next we'll want to install React Native Elements, which is a React Native UI Toolkit that'll provide us with a Card component often seen in mobile apps. We'll also install the vector icons library that's needed to use the Card elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save react-native-elements

npm install react-native-vector-icons --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we'll want to link our new library up&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;react-native link react-native-vector-icons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll also need to add a NSLocationWhenInUseUsageDescription in the Info.plist file otherwise the app will crash. This is just a small description where you state how your app is going to use the location services. So add the following to your Info.plist file in the iOS folder for the project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;key&amp;gt;NSLocationWhenInUseUsageDescription&amp;lt;/key&amp;gt;
&amp;lt;string&amp;gt;YOUR DESCRIPTION HERE&amp;lt;/string&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll also need to add the following to your AndroidManifest.xml for the same reasons&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you're pretty much all setup.&lt;/p&gt;

&lt;p&gt;Firstly, we want to build our card component which will be reused to display the forecasted weather details for every 3 hours.&lt;/p&gt;

&lt;h2&gt;
  
  
  ForecastCard.js
&lt;/h2&gt;

&lt;p&gt;So create a folder called 'components' and inside this create a ForecastCard.js file.&lt;/p&gt;

&lt;p&gt;At the top of the page, we'll want to import React, as well as the StyleSheet, View and Image modules from React Native, as we'll be using these later on.&lt;/p&gt;

&lt;p&gt;We also need to import the Card component from the React Native Elements library we installed.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Firstly we need to setup the ForecastCard's class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
export default class ForecastCard extends Component {


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

&lt;/div&gt;



&lt;p&gt;We're not using any state in this component, it'll just render props that we pass to it from the App parent component, so no need to add a constructor here.&lt;/p&gt;

&lt;p&gt;Inside the render function of the ForecastCard's class we'll want to add the following code to render a blank card for the time being.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return (
    &amp;lt;Card containerStyle={styles.card}&amp;gt;

    &amp;lt;/Card&amp;gt;
);

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

&lt;/div&gt;



&lt;p&gt;Then add the following style to the card, or feel free to add your own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;card:{
    backgroundColor:'rgba(56, 172, 236, 1)',
    borderWidth:0,
    borderRadius:20
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  App.js
&lt;/h2&gt;

&lt;p&gt;Now let's head back to App.js and start working on the App's functionality.&lt;/p&gt;

&lt;p&gt;So let's import all the modules we need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, {Component} from 'react';
import { FlatList } from 'react-native';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice we're importing FlatList, this is a React Native component that we'll be using later on to render a list of items (the ForecastCards)&lt;/p&gt;

&lt;p&gt;We'll be using 4 variables of state:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The longitude of the user's location&lt;/li&gt;
&lt;li&gt;The latitude of the user's location&lt;/li&gt;
&lt;li&gt;The forecast returned from the API&lt;/li&gt;
&lt;li&gt;An error string indicating if there's been an error in the API response&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And then initialise these in the constructor for the class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(props){
    super(props);

    this.state = {
        latitude: 0,
        longitude: 0,
        forecast: [],
        error:''
    };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we'll create the function that'll user Geolocation to return a user's position. So setup a getLocation() function with the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;getLocation(){

    // Get the current position of the user
    navigator.geolocation.getCurrentPosition(
    (position) =&amp;gt; {
        this.setState(
        (prevState) =&amp;gt; ({
            latitude: position.coords.latitude, 
            longitude: position.coords.longitude
            }), () =&amp;gt; { this.getWeather(); }
        );
    },
        (error) =&amp;gt; this.setState({ forecast: error.message }),
        { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
    );
}

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

&lt;/div&gt;



&lt;p&gt;This code simply uses the built in Geolocation services to get the user's current position and then sets the state of the latitude and longitude to the response. Then as setState() is an asynchronous operation, we've added a callback that calls the getWeather() function, which we'll set up next. &lt;/p&gt;

&lt;p&gt;So now that we've got the location of the user stored in the state of the application, we'll use this data to pass it the Weather API to get the forecast for that area.&lt;/p&gt;

&lt;p&gt;So setup a getWeather() function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    getWeather(){

        // Construct the API url to call
        let url = 'https://api.openweathermap.org/data/2.5/forecast?lat=' + this.state.latitude + '&amp;amp;lon=' + this.state.longitude + '&amp;amp;units=metric&amp;amp;appid=YOUR API KEY HERE';

        // Call the API, and set the state of the weather forecast
        fetch(url)
        .then(response =&amp;gt; response.json())
        .then(data =&amp;gt; {
            this.setState((prevState, props) =&amp;gt; ({
                forecast: data
        }));
        })
    }

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

&lt;/div&gt;



&lt;p&gt;In the above, we're constructing a URL string that calls the Weather API's forecast service, and then we're appending the latitude and longitude that we've got stored in the state of the class. After that we're appending the units parameter, to specify that we want the units to be metric, and then we're appending our API key to the end.&lt;/p&gt;

&lt;p&gt;Now that we've got a URL to call, we'll call it using the fetch() method, and using the JSON data to set the state of the forecast variable.&lt;/p&gt;

&lt;p&gt;This will set the state of the forecast to be an array containing 5 days worth of forecast entries for that location.&lt;/p&gt;

&lt;p&gt;Next we'll be using React Native's FlatList component to render a list of cards down the mobile screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;render() {
    return (
        &amp;lt;FlatList data={this.state.forecast.list} style={{marginTop:20}} keyExtractor={item =&amp;gt; item.dt_text} renderItem={({item}) =&amp;gt; &amp;lt;ForecastCard detail={item} location={this.state.forecast.city.name} /&amp;gt;} /&amp;gt;
    );
}

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

&lt;/div&gt;



&lt;p&gt;The FlatList component (&lt;a href="https://facebook.github.io/react-native/docs/flatlist" rel="noopener noreferrer"&gt;https://facebook.github.io/react-native/docs/flatlist&lt;/a&gt;) takes multiple props, firstly we'll provide it with 'data' which is the forecast that we've got stored in state, then we'll point it the 'list' part of the JSON response as this contains each 3 hour block of forecast. Then we'll push the list down by 20px by using the style props, then the keyExtractor props forces the list to use the ids for the keys, rather than the default 'key' props we see in lists (in this case we're giving it the timestamp of the weather forecast item as a unique identifier)&lt;/p&gt;

&lt;p&gt;The following line is where we actually tell React what we want the FlatList to render:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;renderItem={({item}) =&amp;gt; &amp;lt;ForecastCard detail={item} location={this.state.forecast.city.name} /&amp;gt;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we're telling it to render the list with our ForecastCard components we've created.&lt;/p&gt;

&lt;p&gt;However first we need to import it at the top of the App.js file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import ForecastCard from './components/ForecastCard';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're passing it 2 props, detail and location. Detail is basically each iteration of 3 hour weather forecast that we've got from the JSON response from the API call, this means we can access each block of data in each card. Then location is the part of the JSON response that contains the city that the weather forecast is for.&lt;/p&gt;

&lt;p&gt;Now we've got the FlatList setup so we can simply pass all the props through to the ForecastCard.js component we've created.&lt;/p&gt;

&lt;h2&gt;
  
  
  ForecastCard.js
&lt;/h2&gt;

&lt;p&gt;Now we'll add into each card a title, containing the location. For this we'll use the React Native text element, and display the props we're passing to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Text style={styles.notes}&amp;gt;{this.props.location}&amp;lt;/Text&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we'll add the image and time using a View component, and Flexbox to position them on each side:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;View style={{flexDirection:'row', justifyContent:'space-between', alignItems:'center'}}&amp;gt;
    &amp;lt;Image style={{width:100, height:100}} source={{uri:"https://openweathermap.org/img/w/" + this.props.detail.weather[0].icon + ".png"}} /&amp;gt;
    &amp;lt;Text style={styles.time}&amp;gt;{time}&amp;lt;/Text&amp;gt;
&amp;lt;/View&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Notice how we're using the Image Component and passing it the props of the image URL picked out from the JSON response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Image style={{width:100, height:100}} source={{uri:"https://openweathermap.org/img/w/" + this.props.detail.weather[0].icon + ".png"}} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For displaying the time, we're using a variable. We're doing this so we can turn the datestamp into a format that's more user friendly and just has the time. So inside the render function, just before the return statement we'll add this:&lt;br&gt;
&lt;/p&gt;

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

// Create a new date from the passed date time
var date = new Date(this.props.detail.dt*1000);

// Hours part from the timestamp
var hours = date.getHours();

// Minutes part from the timestamp
var minutes = "0" + date.getMinutes();

time = hours + ':' + minutes.substr(-2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will just format our date stamp into a nice easy to read hour format.&lt;/p&gt;

&lt;p&gt;Next to add out divider line we'll use the Divider component, and give it a colour and a little bit of spacing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Divider style={{ backgroundColor: '#dfe6e9', marginVertical:20}} /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the final part of our Card component will be the description and the temperature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;View style={{flexDirection:'row', justifyContent:'space-between'}}&amp;gt;
    &amp;lt;Text style={styles.notes}&amp;gt;{this.props.detail.weather[0].description}&amp;lt;/Text&amp;gt;
    &amp;lt;Text style={styles.notes}&amp;gt;{Math.round( this.props.detail.main.temp * 10) / 10 }&amp;amp;#8451;&amp;lt;/Text&amp;gt;
&amp;lt;/View&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again we'll be using flexDirection and justifyContent to space them at either side of the card. We'll be using 2 Text components, the first to display the part of the JSON response that has the text description in, then the second Text element contains the temperature part of the JSON response, rounded to 1 decimal place to get a nice formatted temperature. Then we'll add the HTML entity&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;#8451;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to add the Celsius symbol.&lt;/p&gt;

&lt;p&gt;Then to style it we'll add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
const styles = StyleSheet.create({
    time:{
        fontSize:38
    },
    notes: {
        fontSize: 18,
        textTransform:'capitalize'
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So overall, we've covered how you can use a FlatList to render a list of Cards, and how you can use Geolocation to get coordinates and how to use this with a Weather API to get a JSON response with the weather forecast for that given location.&lt;/p&gt;

&lt;p&gt;We've also utilised a number of new React Native components, such as Images and FlatLists, as well as an introduction to the React Native Elements library, and how to use Cards and Dividers.&lt;/p&gt;

&lt;p&gt;So simply connect up your phone, and open the Xcode project in Xcode to get it onto your device to give it a test.&lt;/p&gt;

&lt;p&gt;The source code for this app is available here on Github &lt;a href="https://github.com/andrewsmith1996/geolocationWeatherReactNative" rel="noopener noreferrer"&gt;https://github.com/andrewsmith1996/geolocationWeatherReactNative&lt;/a&gt;, and is also showcased on my portfolio here &lt;a href="https://andrewsmithdeveloper.com" rel="noopener noreferrer"&gt;https://andrewsmithdeveloper.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you enjoyed this post, and if you have any questions at all or feedback on my post, code or anything then let me know!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>mobileapp</category>
      <category>react</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to build an image recognition app in React Native in 30 minutes</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Tue, 04 Sep 2018 09:20:52 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/how-to-build-an-image-recognition-app-in-react-native-m6g</link>
      <guid>https://dev.to/andrewsmith1996/how-to-build-an-image-recognition-app-in-react-native-m6g</guid>
      <description>&lt;p&gt;For a few months now I've been fascinated by React Native, and having already done some development in the Ionic framework I was excited by how well an app that renders through native components rather than a webview performs.&lt;/p&gt;

&lt;p&gt;We'll be building a simple app that uses React Native's camera component (&lt;a href="https://github.com/react-native-community/react-native-camera" rel="noopener noreferrer"&gt;https://github.com/react-native-community/react-native-camera&lt;/a&gt;) to take a picture, then passes the Base64 representation of this image to the free Clarifai Predict image API (&lt;a href="https://clarifai.com/" rel="noopener noreferrer"&gt;https://clarifai.com/&lt;/a&gt;) to get a description of what's in the image.&lt;/p&gt;

&lt;p&gt;The Clarifai API is free, really simple to setup and use and will allow us to get a description from what's in an image.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnjhlo5weodw30qtedg4k.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnjhlo5weodw30qtedg4k.png" alt="Screenshots of finished app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tutorial presumes you have NodeJS and React Native installed. If you don't then head over to &lt;a href="https://facebook.github.io/react-native/docs/getting-started.html" rel="noopener noreferrer"&gt;https://facebook.github.io/react-native/docs/getting-started.html&lt;/a&gt; to get started. It also presumes you have a basic understanding of React and NodeJS.&lt;/p&gt;

&lt;p&gt;You'll also need to grab your free Clarifai API key from &lt;a href="https://clarifai.com/developer/account/signup" rel="noopener noreferrer"&gt;https://clarifai.com/developer/account/signup&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What we'll build
&lt;/h2&gt;

&lt;p&gt;We'll be creating 2 React components ourselves:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A camera preview component, which renders the built in React Native Camera component. This will handle the camera's preview and contain all the logic for identifying what's in the image&lt;/li&gt;
&lt;li&gt;A capture button component which handles the user pressing the button to take the picture, as well as the disabled state of the button.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Let's begin
&lt;/h2&gt;

&lt;p&gt;Firstly, you'll need to initialise a new React Native app.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then CD into your new React Native projects directory, and run the following command to boot up the iOS simulator.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Next we'll want to install the built in React Native Camera component that we'll be using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-native-camera --save~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we'll want to link our new library up&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You'll also want to install Clarifai too, which is what we'll be passing our images to to get the identification.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;We'll also need to add a NSCameraUsageDescription in the Info.plist file otherwise the app will crash. This is just a small description where you state how your app is going to use the camera. So add the following to your Info.plist file in the iOS folder for the project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;key&amp;gt;NSCameraUsageDescription&amp;lt;/key&amp;gt;
&amp;lt;string&amp;gt;This app requires the camera to take an image to be identified&amp;lt;/string&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you're pretty much all setup, so you're ready to build our 2 components.&lt;/p&gt;

&lt;p&gt;Firstly, we want to build our camera component which will hold everything else.&lt;/p&gt;

&lt;p&gt;So create a folder called 'components' and inside this create a Camera.js file.&lt;/p&gt;

&lt;p&gt;At the top of the page, we'll want to import React, as well as the Dimensions, Alert, StyleSheet and ActivityIndicator modules from React Native to use.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then we'll want to actually import the React Native Camera module we've installed via NPM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { RNCamera } from 'react-native-camera';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll also import our Capture button component, but we'll come to that later.&lt;/p&gt;

&lt;p&gt;Setup the Camera's class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
export default class Camera extends React.Component {

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

&lt;/div&gt;



&lt;p&gt;Next we'll want to setup the state of our camera component, so create a constructor for the Camera class. We'll need to set 2 variables of state&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The text we want to show in an alert containing the word of what's been identified in the image (which I've called identifiedAs) &lt;/li&gt;
&lt;li&gt;A boolean value to determine whether the camera is in a loading state (for use with the activity indicator when we're identifying what's in the image). &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So your constructor should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(props){
    super(props);

    this.state = { 
        identifedAs: '',
        loading: false
    }
}

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

&lt;/div&gt;



&lt;p&gt;Inside the render function of the Camera class we'll want to add the following code, from the React Native Camera component docs. This will just loading up the built in Camera component from React Native.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;RNCamera ref={ref =&amp;gt; {this.camera = ref;}} style={styles.preview}&amp;gt;&amp;lt;/RNCamera&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's add the button to take the picture, for this we'll create a whole new component.&lt;/p&gt;

&lt;p&gt;Go ahead and create a CaptureButton.js component inside your components folder.&lt;/p&gt;

&lt;p&gt;Inside here we'll want to import the Button and TouchableHighlight components from React Native. As well as the default StyleSheet module and React.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then inside the render function for this class, we'll add a TouchableHighlight component (&lt;a href="https://facebook.github.io/react-native/docs/touchablehighlight" rel="noopener noreferrer"&gt;https://facebook.github.io/react-native/docs/touchablehighlight&lt;/a&gt;) with a Button component inside, to get the default iOS and Android styling. We'll also add our own styles via the default style prop. We'll also need to use the disabled prop, which takes a prop we've passed down from the state of the parent Camera.js component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;TouchableHighlight style={styles.captureButton} disabled={this.props.buttonDisabled}&amp;gt;
    &amp;lt;Button onPress={this.props.onClick} disabled={this.props.buttonDisabled} title="Capture" accessibilityLabel="Learn more about this button"/&amp;gt;
&amp;lt;/TouchableHighlight&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll want to add a press event to this Button too, so that it knows what to do when the user presses it (i.e take the picture and identify from it). For this we'll add an onPress event and give it the props from the parent Camera.js component we had earlier, which is a function inside Camera.js.&lt;/p&gt;

&lt;p&gt;We'll also want to disable the button when it's been clicked, so for this again we'll use some props passed down from the Camera.js component, as it's ultimately the camera component that determines the state of whether a picture is being taken, rather than the button.&lt;/p&gt;

&lt;p&gt;Let's also add some styling for the button, to just and push it up and give it a background and some rounded corners.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const styles = StyleSheet.create({
    captureButton: {
        marginBottom:30,
        width:160,
        borderRadius:10,
        backgroundColor: "white",
    }
});

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

&lt;/div&gt;



&lt;p&gt;Then simply add this style into the style prop of the TouchableHighlight component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;style={styles.captureButton}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So overall, your Button.js should look like this&lt;br&gt;
&lt;/p&gt;

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

export default class CaptureButton extends React.Component {
    render() {
        return (
            &amp;lt;TouchableHighlight style={styles.captureButton} disabled {this.props.buttonDisabled}&amp;gt;
                &amp;lt;Button onPress={this.props.onClick} disabled={this.props.buttonDisabled} title="Capture" accessibilityLabel="Learn more about this button"/&amp;gt;
            &amp;lt;/TouchableHighlight&amp;gt;
        );
    }
}

const styles = StyleSheet.create({
    captureButton: {
        marginBottom:30,
        width:160,
        borderRadius:10,
        backgroundColor: "white"
    }
});


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

&lt;/div&gt;



&lt;p&gt;Now heading back to your Camera.js component, your render function should be looking like this. We've added some styling for the preview area to via the style props, and we've added our own buttonDisabled props which sends the loading state of the camera down to the child button component. We've also added our onClick props too, and bound this to the takePicture() function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;render() {
    return (
        &amp;lt;RNCamera ref={ref =&amp;gt; {this.camera = ref;}} style={styles.preview}&amp;gt;
            &amp;lt;CaptureButton buttonDisabled={this.state.loading} onClick={this.takePicture.bind(this)}/&amp;gt;
        &amp;lt;/RNCamera&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll want to add an Activity Indicator (&lt;a href="https://facebook.github.io/react-native/docs/activityindicator" rel="noopener noreferrer"&gt;https://facebook.github.io/react-native/docs/activityindicator&lt;/a&gt;) to show the user that the image is being identified.&lt;/p&gt;

&lt;p&gt;So for this let's use React Native's Activity Indicator component, which we imported earlier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ActivityIndicator size="large" style={styles.loadingIndicator} color="#fff" animating={this.state.loading}/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For this we'll want to use the default animating prop and set it the loading state of the class so that when the state is updated the ActivityIndicator will be shown/hidden accordingly.&lt;/p&gt;

&lt;p&gt;So overall, having added our ActivityIndicator and our own Capture Button component, the render function of your Camera.js component should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;render() {
    return (
        &amp;lt;RNCamera ref={ref =&amp;gt; {this.camera = ref;}} style={styles.preview}&amp;gt;
            &amp;lt;ActivityIndicator size="large" style={styles.loadingIndicator} color="#fff" animating={this.state.loading}/&amp;gt;
            &amp;lt;CaptureButton buttonDisabled={this.state.loading} onClick={this.takePicture.bind(this)}/&amp;gt;
        &amp;lt;/RNCamera&amp;gt;
    );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll also add some styling via the StyleSheet module to center the camera's preview and the loading indicator, we'll use the Dimensions import to dynamically make the camera preview take up the entire width and height of the phone screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const styles = StyleSheet.create({
    preview: {
        flex: 1,
        justifyContent: 'flex-end',
        alignItems: 'center',
        height: Dimensions.get('window').height,
        width: Dimensions.get('window').width,
    },
    loadingIndicator: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
    }
});


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

&lt;/div&gt;



&lt;p&gt;So now you should have the UI all sorted, we want to add the functionality to take the picture. So first we want to wire up the click event for the Button.js component we created. Most of this code has been taken from the React Native Camera components docs, but I'll summarise it.&lt;/p&gt;

&lt;p&gt;This wants to be an Async function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;takePicture = async function(){

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

&lt;/div&gt;



&lt;p&gt;Then after checking the camera has been initialised and a picture has been taken, we want to pause the camera's preview, on the photo that we've taken&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Pause the camera's preview
this.camera.pausePreview();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then after this we can simply update the state of the Camera to be calculating the image's tags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Update the state to indicate loading
this.setState((previousState, props) =&amp;gt; ({
    loading: true
}));

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

&lt;/div&gt;



&lt;p&gt;We then want to actually take the picture, and get the Base64 representation of the picture&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Set the options for the camera
const options = {
    base64: true
};

// Get the base64 version of the image
const data = await this.camera.takePictureAsync(options)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we'll call a new function we'll create shortly that takes the Base64 representation of the image and pass it to the Clarifai API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.identifyImage(data.base64);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, using the Clarafai docs, we can initialise Clarafai with your API key and pass the Base64 to its Predict API. Then we'll pass the part of the JSON response that contains the top rated image tag to a new function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;identifyImage(imageData){

    // Initialise the Clarifai api
    const Clarifai = require('clarifai');

    const app = new Clarifai.App({
        apiKey: 'YOUR KEY HERE'
    });

    // Identify the image
    app.models.predict(Clarifai.GENERAL_MODEL, {base64: imageData})
        .then((response) =&amp;gt;  this.displayAnswer(response.outputs[0].data.concepts[0].name)
        .catch((err) =&amp;gt; alert(err))
    );
}

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

&lt;/div&gt;



&lt;p&gt;In the displayAnswer function we'll want to update the state of the application. This will set the state of the alert message as well as disable the Activity Indicator, as well as re-enable all the buttons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Dismiss the acitivty indicator
this.setState((prevState, props) =&amp;gt; ({
    identifedAs:identifiedImage,
    loading:false
}));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we've got the answer we'll just show it on an alert to the user, using React Native's Alert module (&lt;a href="https://facebook.github.io/react-native/docs/alert" rel="noopener noreferrer"&gt;https://facebook.github.io/react-native/docs/alert&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Alert.alert(this.state.identifedAs,'',{ cancelable: false });

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

&lt;/div&gt;



&lt;p&gt;Then we'll resume the camera's preview, so we can take a new picture.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Resume the camera's preview
this.camera.resumePreview();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overall, your displayAnswer() function should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;displayAnswer(identifiedImage){

    // Dismiss the acitivty indicator
    this.setState((prevState, props) =&amp;gt; ({
        identifedAs:identifiedImage,
        loading:false
    }));

    // Show an alert with the answer on
    Alert.alert(this.state.identifedAs,'',{ cancelable: false });

    // Resume the preview
    this.camera.resumePreview();
}

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

&lt;/div&gt;



&lt;p&gt;And your whole Camera.js component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Dimensions, Alert, StyleSheet, ActivityIndicator } from 'react-native';
import { RNCamera } from 'react-native-camera';
import CaptureButton from './CaptureButton.js'

export default class Camera extends React.Component {

    constructor(props){
        super(props);
        this.state = { 
            identifedAs: '',
            loading: false
        }
    }

    takePicture = async function(){

        if (this.camera) {

            // Pause the camera's preview
            this.camera.pausePreview();

            // Set the activity indicator
            this.setState((previousState, props) =&amp;gt; ({
                loading: true
            }));

            // Set options
            const options = {
                base64: true
            };

            // Get the base64 version of the image
            const data = await this.camera.takePictureAsync(options)

            // Get the identified image
            this.identifyImage(data.base64);
        }
    }

    identifyImage(imageData){

        // Initialise Clarifai api
        const Clarifai = require('clarifai');

        const app = new Clarifai.App({
            apiKey: 'YOUR KEY HERE'
        });

        // Identify the image
        app.models.predict(Clarifai.GENERAL_MODEL, {base64: imageData})
        .then((response) =&amp;gt; this.displayAnswer(response.outputs[0].data.concepts[0].name)
        .catch((err) =&amp;gt; alert(err))
        );
    }

    displayAnswer(identifiedImage){

        // Dismiss the acitivty indicator
        this.setState((prevState, props) =&amp;gt; ({
            identifedAs:identifiedImage,
            loading:false
        }));

    // Show an alert with the answer on
    Alert.alert(
            this.state.identifedAs,
            '',
            { cancelable: false }
        )

        // Resume the preview
        this.camera.resumePreview();
    }

    render() {
        return (
            &amp;lt;RNCamera ref={ref =&amp;gt; {this.camera = ref;}} style={styles.preview}&amp;gt;
            &amp;lt;ActivityIndicator size="large" style={styles.loadingIndicator} color="#fff" animating={this.state.loading}/&amp;gt;
            &amp;lt;CaptureButton buttonDisabled={this.state.loading} onClick={this.takePicture.bind(this)}/&amp;gt;
            &amp;lt;/RNCamera&amp;gt;
        );
    }
}

const styles = StyleSheet.create({
    preview: {
        flex: 1,
        justifyContent: 'flex-end',
        alignItems: 'center',
        height: Dimensions.get('window').height,
        width: Dimensions.get('window').width,
    },
    loadingIndicator: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
    }
});


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

&lt;/div&gt;



&lt;p&gt;Now heading back to the top level component, App.js, import your fancy new Camera Component that you've just created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Camera from './components/Camera.js';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then add it between the React Native view.&lt;/p&gt;

&lt;p&gt;So your App.js should look like this&lt;br&gt;
&lt;/p&gt;

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

export default class App extends React.Component {

    constructor(props){
        super(props);
        process.nextTick = setImmediate;
    }

    render() {
        return (
            &amp;lt;View style={styles.container}&amp;gt;
                &amp;lt;Camera /&amp;gt;
            &amp;lt;/View&amp;gt;
        );
    }
}

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

&lt;/div&gt;



&lt;p&gt;So overall our simple application has been split up into 3 components, the app itself, our own camera component, and our button component. Then on top of this we're using the  built in React Native Camera component.&lt;/p&gt;

&lt;p&gt;We've also utilised a number of standard React Native components, such as Alerts, Activity Indicators, StyleSheets, TouchableHighlight and Buttons.&lt;/p&gt;

&lt;p&gt;So simply connect up your phone, and open the Xcode project in Xcode to get it onto your device to give it a test.&lt;/p&gt;

&lt;p&gt;The source code for this app is available here on Github &lt;a href="https://github.com/andrewsmith1996/Image-Recogition-React-Native" rel="noopener noreferrer"&gt;https://github.com/andrewsmith1996/Image-Recogition-React-Native&lt;/a&gt;, and is also showcased on my portfolio here &lt;a href="https://andrewsmithdeveloper.com" rel="noopener noreferrer"&gt;https://andrewsmithdeveloper.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you enjoyed this post, and if you have any questions at all or feedback on my post, code or anything then let me know!&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>mobileapp</category>
      <category>ai</category>
      <category>react</category>
    </item>
    <item>
      <title>Explain Unit Testing like I'm five</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Wed, 09 May 2018 09:44:59 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/explain-unit-testing-like-im-five-2m3e</link>
      <guid>https://dev.to/andrewsmith1996/explain-unit-testing-like-im-five-2m3e</guid>
      <description></description>
      <category>explainlikeimfive</category>
      <category>testing</category>
      <category>unittesting</category>
    </item>
    <item>
      <title>Explain MVC like I'm five</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Fri, 16 Mar 2018 08:29:33 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/explain-mvc-like-im-five--4f7l</link>
      <guid>https://dev.to/andrewsmith1996/explain-mvc-like-im-five--4f7l</guid>
      <description></description>
      <category>explainlikeimfive</category>
      <category>mvc</category>
    </item>
    <item>
      <title>What I've learnt in the first six months of my internship.</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Mon, 11 Dec 2017 21:01:43 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/what-ive-learnt-in-the-first-six-months-of-my-internship-41d</link>
      <guid>https://dev.to/andrewsmith1996/what-ive-learnt-in-the-first-six-months-of-my-internship-41d</guid>
      <description>&lt;p&gt;I’ve officially been at my internship as a Junior Web Developer for six months now, which ultimately means that I’m roughly halfway through, before I return to University to complete my final year of my BSc (Hons) in Computer Science next year.&lt;/p&gt;

&lt;p&gt;It’s been an amazing journey. I’ve learnt so much, not only just about technology, but most importantly; about life and how the world works. So below I outline the most important things I’ve learnt.&lt;/p&gt;

&lt;h1&gt;
  
  
  You need to be out of your comfort zone to grow
&lt;/h1&gt;

&lt;p&gt;Quite possibly the hardest, yet most valuable lesson I’ve learnt in my first internship is that things are hard, and things are easy, and things will continue to be hard, and things will continue to be easy. For me, being a software developer is a continuous cycle of being outside of your comfort zone, learning and finding your way back into your comfort zone, heading out of your comfort zone as you learn the next thing, and then repeating the cycle. Sound familiar? This is such a core concept of software development, and quite frankly career development within any technical industry; learning.&lt;/p&gt;

&lt;p&gt;There were times where I felt horrible. Stressed out about projects, deadlines, concepts and theories that I wasn’t quite understanding, I often felt confronted with the fight or flight dilemma. I recall one particular instance when I arrived at work at 8am to find something that had launched the day before was discovered to have some bugs that had somehow survived through testing, and some amends needed to be done. Being a Junior Developer without much live project experience, I naturally panicked and stressed. Chugging coffee and stressing, sat on the edge of my chair, heart-pound as I’m clicking and typing at incredible speed. Ultimately, spending all morning stressing out and rushing to fix the bugs, panicking that it was live, feeling at fault. But what I later realised was that if I stayed calm, breathed and not took it to heart so much then I would have A) saved myself a hell of a lot of stress, imposter syndrome and frustration and B) probably fixed the bugs more effectively and efficiently.&lt;/p&gt;

&lt;p&gt;But it was in these scenarios where I grew the most. Looking back now, this was the most valuable lesson I learnt of all, and the one that I’m most truly grateful for. I’ve learnt how to deal with and react to stressful situations, how to remain calm and keep myself in check; a valuable lesson that is guaranteed to be a useful one for the future. Especially in a world where imposter syndrome can be met at every corner.&lt;/p&gt;

&lt;p&gt;I’ve learnt that it’s not the end of the world if something goes wrong, yes it may potentially have repercussions, but just breathe and stay calm, it will all be okay. To become a good runner, you need to run, to become a good violinist, you need to play the violin, to become good at handling stress, you need to experience stress. For me, a bit of tough love and the exposure to stressful and anxious situations has not only grown me up, but it’s allowed me to gain the experience to deal with stress.&lt;/p&gt;

&lt;h1&gt;
  
  
  You NEED to take care of yourself, physically and mentally
&lt;/h1&gt;

&lt;p&gt;This is something I’ve always been an advocate of, even before I started working 40 hours a week full-time, but it was once I started churning out 40 hours a week, getting up at 6am and often getting back at 6pm that I realised the importance of this; you need to take care of yourself. Your body and your mind should always come first.&lt;/p&gt;

&lt;p&gt;As a developer, it’s easy to sit at your desk all day, hack away, and then head home and sit yourself in front of the TV for the evening. To be honest, if you drive into work, it’s easy to go for days without any real form of exercise and to not reach your advised 10,000 steps a day. This goes for eating right too, a healthy balanced diet too is also so easy to ignore.&lt;/p&gt;

&lt;p&gt;Generally for me, staying physically healthy and eating right makes me so much more productive, it generally makes me more confident in what I do, it makes me feel great and more energised, and all together this equates to an increased performance in my job. I find that even little things such as staying hydrated is something that people rarely do, yet seems to work for me. I always aim to get up every hour, and have a glass of water at my desk at all times. It’s these little things that matter.&lt;/p&gt;

&lt;p&gt;Burnout is a real thing. I’d gone a while without any form of significant break from work and it’s only really when I was on a week-long break did I realise that actually, I was pretty burnt out. I  felt like, as J.R.R Tolkien put it, “like butter scraped over too much bread”. I was finding things quite difficult that previously I’d been comfortable with, my ideas weren’t the greatest, and generally I was exhausted, fatigued and the 3pm slump was now a 3pm plummet as my mind became blocked and my energy levels dropped.&lt;/p&gt;

&lt;p&gt;Mental health is a serious thing, I’m a firm believer that you should treat your mental health with as much, if not more, care as your physical health. To me it all starts in the mind. For me, things such as taking regular breaks at work, having a laugh, going outside for a walk and listening to music on my lunch break were all things that got me refreshed and set me back on the right course at work. At home, things such as shutting off notifications and putting my phone on ‘do not disturb’, taking time to pursue my hobbies and interests, escaping into a game, book or TV series and getting enough sleep were all things that I’ve found help deal with burnout, and generally keep me relaxed. As well as these, mindfulness is something that also works wonders. It’s definitely something worth checking out.&lt;/p&gt;

&lt;p&gt;To me, health is something that so many people ignore, they let life take over and get into a routine where it’s easy to neglect yourself. I’ve experienced this, and it’s very easy to do. But really, you are the first thing that you should take care of. Wellness comes from within, and ensuring this is something that has had benefits within every aspect of my life, not just within my career, but my relationships, family, friends and education have all benefited from this. Treat your body like a temple, and you’ll be amazed at the increase in productivity, energy and well-being that you’ll be rewarded with.&lt;/p&gt;

&lt;h1&gt;
  
  
  Drive
&lt;/h1&gt;

&lt;p&gt;I’d always been a driven and ambitious individual, after two years of college and two years at University, my CV is stocked full of extra projects and experience that I’ve absolutely loved doing. But this internship gave me an even bigger drive boost I didn’t even know was possible.&lt;/p&gt;

&lt;p&gt;As soon as I started working with and using modern, industry standard, technologies on a day-to-day basis I suddenly wanted to know EVERYTHING. From little things such as reading up on tech blogs and tech news over my breakfast coffee, to taking part in extra online courses and programs to mop up my development skills, I suddenly became incredibly career driven. I constantly had twenty tabs open relating to things such as tech blogs, courses, LinkedIn discussions, networking events, articles on random tech topics I found interesting, an endless goldmine of things that I wanted to know and read about. Suddenly I felt so involved, I quickly became active in the tech community. I began to write and blog, showcasing my own thoughts and ideas into the tech community. I wanted to be involved and I wanted to talk to like-minded people.&lt;/p&gt;

&lt;h1&gt;
  
  
  Do it properly, the devil is in the detail
&lt;/h1&gt;

&lt;p&gt;At University, many of my projects didn’t involve coding with other people, no collaboration. So when spaghetti code was written and little hacks or hot fixes here and there were implemented, it didn’t really have that many repercussions. In industry however, 90% of the time I was working in a team, and 100% of the time I knew somebody, someday would pick up my code and read it and add to it.&lt;/p&gt;

&lt;p&gt;On a day-to-day basis I was collaborating with others to build systems, that had to work, and had to work well. At the beginning of my internship, my coding skills weren’t that great, I’ll stand up and admit that. I mean, the stuff I wrote worked, but often the code could have been better. Later down the line, when I knew others would be reading and adding to my codebase I realised that I need to be detailed in my approach, my code needed to be refactored well and it needed to be efficient, readable and well documented. Things mattered here, and I couldn’t be lazy, it needed to be done properly. Industry standard and organised.&lt;/p&gt;

&lt;p&gt;You can’t hide in industry. No hacks or quick fixes. No quickly getting things built. They needed to be done correctly, because you never know who will pick the codebase up in X number of months. Do it properly, take your time, be detailed. If it takes time, then it takes time, but it’ll be so much more worth it when you end up writing a solid, organised and efficient codebase that you can be proud of.&lt;/p&gt;

&lt;p&gt;This is the same for version control (one of the most important technical skills I’ve gained from working in industry), I quickly discovered how great version control was for collaboration. The process of branching off from production, writing code, merging back in and pushing, and potentially getting merge conflicts was something that taught me the values of teamwork, communication and it made it evident how much can actually be achieved when working as a team.&lt;/p&gt;

&lt;h1&gt;
  
  
  Imposter syndrome is real, and boy it can be dangerous
&lt;/h1&gt;

&lt;p&gt;Now this is a lesson that I learnt the hard way. Software developers are notoriously famous for experiencing “imposter syndrome” or feeling “like you’re a fraud and the whole world is going to find you out.” Often, I was thrown in the deep end with my internship. Especially early days when I was still adjusting to the 40 hour week. In my opinion University just doesn’t prepare you for the working world well enough. But the deep end was where I grew the most, yes it took time to get afloat, but as previously stated, nothing makes you grow like being outside of your comfort zone.&lt;/p&gt;

&lt;p&gt;Often I was thrown into projects that I found difficult, an array of new technologies, concepts and methodologies that I was expected to learn and build a successful and well-functioning system with, and often this was difficult for a twenty year old intern to take in. Especially when deadlines and time constraints were thrown into the mix. Often thoughts such as “am I cut out for this?” and “do all interns feel like this?” popped up, and sometimes these would spiral out of control into a whirlwind of self-doubt, unconfidence and anxiety. There were days when my confidence was absolutely shot, I felt stuck and I felt like I wasn’t getting anywhere. I just didn’t feel good enough. But then next day, all it’d take was some success with a project and suddenly it was gone, it flipped over and suddenly I’d become more confident in my abilities and aware of myself.&lt;/p&gt;

&lt;p&gt;Eventually I learnt to deal with this better, through reminding myself of my skillset, reminding myself how far I’d come and how much I actually did know. I won’t lie, I’ve still not figured out how to completely avoid imposter syndrome, but to be honest I don’t know if I ever will. I think it’s just a part of life, in any career path. However little things such as explaining concepts to other people, looking back at old projects to see how far I’ve come, doing something I know I’m good at all helped. Another thing worth mentioning is how supportive the tech community is of this. So many times I looked towards blog posts and articles on imposter syndrome within software developers for help and advice. This was probably the best thing I could have done to deal with imposter syndrome. It was comforting to know that I wasn’t alone in this feeling, and that it’s a common occurrence not only in Junior Developers, but also experienced Senior Developers. It’s important to stay calm, and remind yourself how great you are, and how far you’ve come.&lt;/p&gt;

&lt;p&gt;I find that confidence is key here, it’s important to be confident, it may be hard, but be confident in your abilities. It’s gotten you this far after all, hasn’t it?&lt;/p&gt;

&lt;h1&gt;
  
  
  To make the best of your internship, you need to get an all-round experience
&lt;/h1&gt;

&lt;p&gt;I’ve been exposed to so much in my internship, from the initial design of front-end interfaces through wireframes and PSD files, to building complex database queries with more than four joins, to using version control within a team environment, to micro-managing my own projects and conforming to deadlines. Everything that I got exposed to has helped advance my career, knowledge and skillset in some way or another. I began the internship having only University and freelance project experience, but six months in an agency with developers, designers and a manager has taught me so much, across such a broad spectrum of things. With a broad foundation of knowledge across multiple areas of software development, I now know that I can specialise in a certain area and still be able to work with someone who specialises in another area. For example, having designed some wireframes for a particular interface in my internship, I now know that in X amount of years, if I’m building an interface myself, I can talk to a designer about the wireframes and design behind it. Not only does this improve communication between teams and individuals, but it also results in an increased development of whatever it is that is being built.&lt;/p&gt;

&lt;p&gt;A key piece of advice I’d give to any interns, or anyone that is starting out in software development is to gain exposure to as much as possible. Even if you don’t see yourself going into that area in the future, or even if you don’t particularly enjoy that specific area; learn and experience it. It may even give you the edge over other candidates in a job application. You’re young, so try to see it all, and try to fill your head with as much knowledge as you possibly can, an internship only lasts so long, so make the most of it.&lt;/p&gt;

&lt;p&gt;An internship is hard, especially when it’s your first. But stick with it, it’ll all be worth it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nothing worth having comes easy.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>intern</category>
      <category>developer</category>
      <category>new</category>
    </item>
    <item>
      <title>Explain like I'm five: AngularJS and when you'd use it.</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Tue, 24 Oct 2017 06:21:14 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/explain-like-im-five-angularjs-and-when-youd-use-it-82o</link>
      <guid>https://dev.to/andrewsmith1996/explain-like-im-five-angularjs-and-when-youd-use-it-82o</guid>
      <description></description>
      <category>explainlikeimfive</category>
      <category>framework</category>
      <category>frontend</category>
    </item>
    <item>
      <title>How do YOU deal with imposter syndrome?</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Mon, 09 Oct 2017 11:26:11 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/discussion-how-do-you-deal-with-imposter-syndrome-cd2</link>
      <guid>https://dev.to/andrewsmith1996/discussion-how-do-you-deal-with-imposter-syndrome-cd2</guid>
      <description>&lt;p&gt;How do &lt;strong&gt;YOU&lt;/strong&gt; dealwith imposter syndrome?&lt;/p&gt;

</description>
      <category>impostersyndrome</category>
      <category>juniordeveloper</category>
      <category>discuss</category>
      <category>junior</category>
    </item>
    <item>
      <title>Quickfire Discussion: I'm a Junior Developer, tell me your top 3 pieces of advice.</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Sun, 08 Oct 2017 14:15:18 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/quickfire-discussion-im-a-junior-developer-tell-me-your-top-3-pieces-of-advice-5fp</link>
      <guid>https://dev.to/andrewsmith1996/quickfire-discussion-im-a-junior-developer-tell-me-your-top-3-pieces-of-advice-5fp</guid>
      <description>&lt;p&gt;Quickfire Discussion: I'm a Junior Developer, tell me your top 3 pieces of advice.&lt;/p&gt;

&lt;p&gt;What did you wish you knew when you were a Junior Developer?&lt;/p&gt;

&lt;p&gt;What would you tell current Junior Developers?&lt;/p&gt;

&lt;p&gt;etc&lt;/p&gt;

</description>
      <category>juniordeveloper</category>
      <category>advice</category>
      <category>discuss</category>
      <category>intern</category>
    </item>
    <item>
      <title>Why kids should learn to code</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Sat, 07 Oct 2017 14:52:38 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/why-kids-should-learn-to-code-6oa</link>
      <guid>https://dev.to/andrewsmith1996/why-kids-should-learn-to-code-6oa</guid>
      <description>&lt;p&gt;Steve Jobs once said “Everybody in this country should learn to program a computer, because it teaches you how to think”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;But why?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kids in school today are taught a wide variety of things, from core mathematics to Biology to Spanish to English, there are absolutely dozens of subject areas that each generation of the future’s minds are being taught and then tested on each year. But when you actually think about it, through this are we teaching them the right skills? What do kids actively learn from this? Now (DISCLAIMER) please don’t get me wrong, I’m not saying “Hey, let’s change up the national curriculum, because I have an opinion on something”, very far from it even. I believe what we currently teach is great, but I simply believe that Computer Science and Information Technology subjects are being ignored and are lagging behind, and I believe we need to start kids on these sort of courses earlier. For me this all comes down to one question, are we teaching kids the right skills? Not knowledge in the form of facts and recallable information, but skills. Actual applicable abilities and capacities that people know how to use.&lt;/p&gt;

&lt;p&gt;If you go out today, and ask a child “what is the powerhouse of a cell?”, I bet they could answer. “Mitochondria” they quickly fire back at you. You think great, this child knows their Biology, and could potentially make a great Biologist one day. But however, give them a problem domain relating to Biology and then ask them to solve this problem and I bet this test is more challenging for them, they might take more time, they might have to give multiple attempts or they may even give up completely. &lt;/p&gt;

&lt;p&gt;This is because the ability to solve problems is significantly different and varied from the ability to recall knowledge. After all, the human memory supposedly has an infinite capacity to store knowledge for potential later use, it even has Psychologist George Miller’s 7 (plus or minus 2) concept for storing short term information for quick-fire recollection. However using knowledge to solve problems is a much more complicated neurological process, involving a multitude of electrochemical signals formed within neurons that move along axons to jump from one neuron to another across synapses through neurotransmitter chemicals being released. Sounds much more complicated, right?&lt;/p&gt;

&lt;p&gt;When you think about it, in school, how often were/are you challenged to solve a problem. But first, when I say solve a problem I mean the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You are given a problem domain, that is essentially, something to solve.&lt;/li&gt;
&lt;li&gt;You have an initial state, that is where you currently are. &lt;/li&gt;
&lt;li&gt;You have a goal state, that is where you want to be/a desired outcome.&lt;/li&gt;
&lt;li&gt;The means to get from the initial state to the goal state are unknown, and you are required to reach this goal state through forming a bunch of intermediate states, or instructions. With each intermediate state taking you one step closer to the goal state and one step further away from the initial state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So to me, problem solving can simply be defined as the arrow in the middle of the following statement:&lt;/p&gt;

&lt;p&gt;Initial State -&amp;gt; Goal State&lt;/p&gt;

&lt;p&gt;(With the arrow being potentially a lot of frustration, pain and Stack Overflow, although with a significant amount of learning)&lt;/p&gt;

&lt;p&gt;So back to the point, problem solving can be difficult, and effectively, programming can be seen as problem solving. &lt;/p&gt;

&lt;p&gt;At the start of any programming project, small or large, you are given a problem domain, or something to solve. For example, “write a program that outputs the Fibonacci sequence” or “write a program that outputs the names of every string in an array but without any vowels in it”. Essentially, you are required to think about how to approach each problem, and then using a variety of programming concepts such as flow control, variables, input and output, structures, objects, strings, arrays, mathematics, functions (etc) to create/construct a solution to the problem. That is, you use core programming concepts to reach a desired outcome. &lt;/p&gt;

&lt;p&gt;Now we’ve made the link between programming and problem solving, let’s talk about the real question I’m answering; why kids should learn to code. &lt;/p&gt;

&lt;p&gt;When kids learn to code, they are learning to solve problems. They’re actively being given initial states and goal states, and they are being made to think up ways to create the intermediate states in between, to eventually reach the desired outcome. I do not believe one gets exposure to this sort of practical, theoretical and significantly challenging thinking from any other subject, maybe mathematics or physics, but with this you are implementing other people’s solutions to problems, instead of creating your own. So surely challenging the younger generation to become better at thinking in this way will result in more problems in the future being solved, right? I believe that instead of teaching kids a whole bunch of information that in a job they are required to simply recall and apply to scenarios, how about we teach them how to create their own solutions to scenarios, and we teach them how to think rather than how to recall information.&lt;/p&gt;

&lt;p&gt;Ultimately, I believe that Computer Science, and any educational subject that gives exposure to programming and coding teaches an immense range of skills that no other subject at school even remotely touches upon; practically solving problems and creating solutions to problems. In essence, programming makes you think, and boy does it make you think hard. So through pushing the benefits of learning to code, let’s make kids think in a way that is practical, theoretical, productive, active, engaging, stimulating, creative and also, pretty damn fun.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Do you ever get frustrated with your Junior Developer(s)?</title>
      <dc:creator>Andrew Smith</dc:creator>
      <pubDate>Sat, 07 Oct 2017 12:56:08 +0000</pubDate>
      <link>https://dev.to/andrewsmith1996/do-you-ever-get-frustrated-with-your-junior-developers-b84</link>
      <guid>https://dev.to/andrewsmith1996/do-you-ever-get-frustrated-with-your-junior-developers-b84</guid>
      <description>&lt;p&gt;Having recently started a new internship as a Junior Software Developer, I can't help but feel like I (significantly) &lt;strong&gt;&lt;em&gt;annoy&lt;/em&gt;&lt;/strong&gt; everyone with my (very) &lt;strong&gt;&lt;em&gt;frequent&lt;/em&gt;&lt;/strong&gt; questions.&lt;/p&gt;

&lt;p&gt;Don't get me wrong, I know in myself that it's a necessity to ask questions as a Junior Dev, because after all that's how you learn and gain experience, right? So I understand that I am not in the wrong by asking questions, but I often do wonder, does this get annoying for the people (most often Senior Devs) answering my questions? After all I'm taking them from their time pressured work, I'm asking them to explain something that I'm finding difficult but they probably can do in their sleep and I'm generally taking time from their day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So my question is, do you ever get frustrated with your Junior Developer?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>juniordeveloper</category>
      <category>frustration</category>
      <category>impostersyndrome</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
