<?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: Andreas Bergqvist</title>
    <description>The latest articles on DEV Community by Andreas Bergqvist (@andreasbergqvist).</description>
    <link>https://dev.to/andreasbergqvist</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%2F153873%2Fe179c98f-7ed8-44d0-aff8-529fb72c0aff.jpg</url>
      <title>DEV Community: Andreas Bergqvist</title>
      <link>https://dev.to/andreasbergqvist</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andreasbergqvist"/>
    <language>en</language>
    <item>
      <title>Web site checklist - for developers</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Thu, 02 Jun 2022 18:08:56 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/web-site-checklist-for-developers-11ff</link>
      <guid>https://dev.to/andreasbergqvist/web-site-checklist-for-developers-11ff</guid>
      <description>&lt;p&gt;There is a rich landscape of tools, frameworks and CMSes that greatly increase your productivity when building a web site. So when a path is selected, a design is implemented - there are just a few more things to consider to finalize your great accomplishment.&lt;/p&gt;

&lt;p&gt;☑️ images should be minimized and delivered in best possible format (webp)&lt;br&gt;
☑️ images should be resized to match actual size and be lazy loaded&lt;br&gt;
☑️ make sure site is cached in best way&lt;br&gt;
☑️ server should serve http/2 (or http/3)&lt;br&gt;
☑️ add http caching so that files are cached in the browser&lt;br&gt;
☑️ sitemap should exist - and added to Google Search console&lt;br&gt;
☑️ robot should be able to crawl site&lt;br&gt;
☑️ meta description should exist on pages&lt;br&gt;
☑️ links and buttons should be clickable without mouse&lt;br&gt;
☑️ buttons with no text should have aria-label&lt;br&gt;
☑️ header-tags should be in order&lt;br&gt;
☑️ symantic html with main, nav, section and so on&lt;br&gt;
☑️ images have describing alt texts&lt;br&gt;
☑️ user should be able to tab through all interactive elements&lt;br&gt;
☑️ input fields should have labels&lt;br&gt;
☑️ make sure cache (including JavaScript and CSS files) is invalidated on deploy or content update&lt;br&gt;
☑️ if there is an existing site that are being updated, add redirects from old URLs to new&lt;br&gt;
☑️ analytics should be implemented&lt;br&gt;
☑️ no cookies should be saved before user consent&lt;br&gt;
☑️ sharing in social media should include editable title, description and image&lt;br&gt;
☑️ browsers used by the majority or your users should be supported and tested&lt;br&gt;
☑️ created 404 page&lt;br&gt;
☑️ add a descriptive readme file - another developer should easily be able to get the project up and running with the information&lt;br&gt;
☑️ branching workflow in git should be documented in readme file&lt;br&gt;
☑️ any environment specific settings should exist in a .env file (an .env.example file should be added to git)&lt;br&gt;
☑️ use addons/plugins/extensions that debug memory and database usage locally&lt;br&gt;
☑️ add error reporting for frontend and backend in production&lt;br&gt;
☑️ document any password or key in a password manager&lt;br&gt;
☑️ linting of the code should be configured and forced by other developers (though git workflows or deployment)&lt;/p&gt;

&lt;p&gt;Cool, now we are done!&lt;/p&gt;

</description>
      <category>web</category>
      <category>developer</category>
      <category>checklist</category>
    </item>
    <item>
      <title>Teaching React</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Mon, 28 Dec 2020 21:30:10 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/teaching-react-4bfa</link>
      <guid>https://dev.to/andreasbergqvist/teaching-react-4bfa</guid>
      <description>&lt;p&gt;I'm a developer who was worked professionally since the beginning of 2000 with mostly web development.&lt;/p&gt;

&lt;p&gt;Since a few years I've worked quite a lot with React (and React Native) and are REALLY enjoying it!&lt;/p&gt;

&lt;p&gt;Recently I got a question from a school to be involved in a React education for people already in the industry (web development) who wants to learn React.&lt;/p&gt;

&lt;p&gt;Since I really enjoy React, and also love to spread my knowledge to other developers, I accepted (together with a co-worker) it! How hard could it be?&lt;/p&gt;

&lt;p&gt;When it comes to all the details of React, it might not actually be that easy, as it seemed... =) I'll try to explain why.&lt;/p&gt;

&lt;h3&gt;
  
  
  The history
&lt;/h3&gt;

&lt;p&gt;React has been a open source project by Facebook for quite some years now (since 2013). Me personally is very happy with the current state of things in the React ecosystem. But a lot of things has happened during these years and I can imagine a lot of people being frustrated with ever changing "trends" on how to build stuff.&lt;/p&gt;

&lt;p&gt;But except for the much appreciated hooks-update, we at Itiden (were I work) has kind of gathered our favorite libraries around the core React libs, and for the last 1-2 years stuck with that, and been really happy with it.&lt;/p&gt;

&lt;p&gt;But this also makes it kind of hard to teach, since I would like to teach the way we work with it. But also understand that not everyone does it that way... I'll try to explain how we do it, and why.&lt;/p&gt;

&lt;h3&gt;
  
  
  Functional components vs Class components
&lt;/h3&gt;

&lt;p&gt;Short story, we like and only use functional components.&lt;/p&gt;

&lt;p&gt;I would like to focus the education on functional components and not go in to Class components to much.&lt;/p&gt;

&lt;p&gt;But I guess a basic understanding is "nice to have". Since old documentation and examples might be written with classes. And also, some might get to work in "old" (old is relative in this case =) projects that uses classes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Global state
&lt;/h3&gt;

&lt;p&gt;In bigger (and it does not even have to be that big) projects you will at sometime need to store state that is globally available (and not sent with props to all components).&lt;/p&gt;

&lt;p&gt;Nowadays, this is quite easily done with the Context API and useState hooks.&lt;/p&gt;

&lt;p&gt;But when to gets a little bit more complex, you would probably use useReducer or even a third-party library to handle state.&lt;/p&gt;

&lt;p&gt;I have never come to like Redux (the most commonly used third-party library). The amount of boilerplate (yeah, I've heard about Redux toolkit and that might fix this) and the difficulty I've had to just read code that used Redux and understand it has just not worked for me. And when it comes to useReducer, it kinda reminds me of Redux and I'm having trouble (might be a native language thing, English is not my native language) understanding the "reducer" part.&lt;/p&gt;

&lt;p&gt;And a few years ago, to the rescue came &lt;strong&gt;Mobx&lt;/strong&gt;.&lt;br&gt;
It was kind of a "hallelujah moment" when it was released and me together with my colleagues looked at the documentation and how you would write code with it. Since then, we have used Mobx in almost all projects.&lt;/p&gt;

&lt;p&gt;But I understand that we can't just focus on Mobx in the education. I'm aware that more project are using other solutions, then are using Mobx.&lt;/p&gt;

&lt;h3&gt;
  
  
  Styling
&lt;/h3&gt;

&lt;p&gt;When React was released, there was a debate about how the hell you could suddenly mix logic (the Javascript part) with HTML and styling. We have all learned that these three should all be split up in .html, .js and .css files!&lt;/p&gt;

&lt;p&gt;Since then, I would say that most people (that have used React or any other of the major Javascript frameworks) agree on that it actually isn't that bad, and actually quite nice even to keep things together in component file.&lt;/p&gt;

&lt;p&gt;Still, there are multiple ways of styling components. While it is fully possible (and I guess quite widely used) to write styling in a separate css (or sass/less) file, with the use of Javascript to write your HTML (JSX in React) along came the idea of writing CSS in Javascript. Quite some libraries have been released to help the developer to accomplish that. But we have agreed (and are enjoying it) to use &lt;strong&gt;Styled Components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But what should you educate? I guess we'll keep the discussion open on what to use, but it will be hard not to prefer Styled Components :-)&lt;/p&gt;

&lt;h3&gt;
  
  
  The directory structure
&lt;/h3&gt;

&lt;p&gt;When you start your small React project I wouldn't overthink this to much. But when a project grows, I think it is a good idea to think about where you put your files and how to name them.&lt;/p&gt;

&lt;p&gt;There are two major "ways" of structuring your files. By type of file (like component, page, util, service etc.) or by features (group components, services etc. that belong together).&lt;/p&gt;

&lt;p&gt;While I understand the second way (by feature), we have kind of stuck with the more "basic" (and more widely used I would say) way of just structuring the files by type.&lt;/p&gt;

&lt;p&gt;But this is very much a matter of personal opinion.&lt;/p&gt;

&lt;p&gt;When it comes to naming you component files, there are also multiple ways. You could keep a directory structure with a folder named after each Component and a index file exporting the components. This I would say work best if you would have multiple files, like tests in the same folder. Otherwise, keep it simple.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing
&lt;/h3&gt;

&lt;p&gt;I would like to teach some fundamentals regarding testing your React code. I would use Jest and React Testing Library och teach how to do some basic tests. This was actually harder than I estimated. I guess, coming from a web development background where you haven't written tests (as most student seemed). Also, when trying Typescript or Next.js, it seemed like some have more problems configuring their tests then writing the actual application. And I understand them, setting up your tests is not easy.&lt;/p&gt;

&lt;p&gt;But I guess, when figuring out the setup, the next question is what to test and when? It is not an easy question to answer. The answer was, most of the time, test things that would make you feel more secure about your code. Still, not easy...&lt;/p&gt;

&lt;p&gt;And I can honestly say, that I build quite some React apps, without or with minimal tests. And that is fine also.&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript
&lt;/h3&gt;

&lt;p&gt;I really enjoy using Typescript (I have probably forgot about the initial learning problems) and nowadays I have problems not using it. But for this course I wanted to focus on the React part, and not let the student get caught on type problems.&lt;/p&gt;

&lt;p&gt;But also, since a lot of code written today in React uses TypeScript, I didn't want to completely exclude it.&lt;/p&gt;

&lt;p&gt;So, there was an optional part, where the student was able to learn about TypeScript. And I actually think a lot of them actually liked it and understood the pros (and to some degree the cons) of using it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;The parts that seemed hardest to get (except for getting the tests to run) was the idea of a function that can be run multiple times, but render the "same" components. The idea of a useEffect function and set state function that are not synchronous. Especially the dependency array for useEffect (and useCallback/useMemo) seem to be hard to get a good understanding of. I guess building stuff and making your errors eventually makes you understand =)&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Build an React Native app. Part 2: Distribution</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Thu, 20 Feb 2020 09:14:17 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/build-an-react-native-app-part-2-distribution-2ddl</link>
      <guid>https://dev.to/andreasbergqvist/build-an-react-native-app-part-2-distribution-2ddl</guid>
      <description>&lt;p&gt;At &lt;a href="https://www.itiden.se"&gt;Itiden&lt;/a&gt; we build web applications and mobile apps.&lt;br&gt;
For both we really enjoy using React &amp;amp; React Native.&lt;/p&gt;

&lt;p&gt;This blog post is a informational post to my talk at React meetup in Gothenburg in two parts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/andreasbergqvist/build-an-react-native-app-part-1-development-250d"&gt;Build an React Native app. Part 1: Development&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Build an React Native app. Part 2: Distribution (this)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have open sourced an React Native app called "Guess the Repo" that uses the libraries we have decided on. It's a quiz app with questions about Github repos. Read more about the app on &lt;a href="https://guesstherepo.itiden.se"&gt;https://guesstherepo.itiden.se&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's not in anyway a spectacular app. But it's quite easy to get up and running if you would like to see how an React Native app can be done.&lt;/p&gt;
&lt;h2&gt;
  
  
  Distribution
&lt;/h2&gt;

&lt;p&gt;For distributing apps we have been using Visual Studio App Center from Microsoft. It was previously known as HockeyApp and has been a distribution service for quite some time.&lt;/p&gt;

&lt;p&gt;But since it becoming App Center alot of more functionality has been built in and I'll try to briefly explain how we are using them.&lt;/p&gt;

&lt;p&gt;Short desciption from &lt;a href="//appcenter.ms"&gt;https://appcenter.ms&lt;/a&gt;: "Continuously build, test, release, and monitor apps for every platform.".&lt;/p&gt;
&lt;h3&gt;
  
  
  Building
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qzbV1Wl2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hgy0r6brnmwacriuhsl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qzbV1Wl2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hgy0r6brnmwacriuhsl5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
From within App Center we can create an React Native app for Android and one for iOS. We connect the apps to the repo from GitHub, ButBucket, GitLab or Azure Devops. Your can setup one build config per branch in your repo.&lt;/p&gt;

&lt;p&gt;You need to update your app first by adding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add appcenter appcenter-analytics appcenter-crashes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are also a few updates to you iOS and Android apps you need to do. But there are guides to follow in the App Center docs.&lt;/p&gt;

&lt;p&gt;When done you can setup a bunch of build settings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js version&lt;/li&gt;
&lt;li&gt;Xcode version (for iOS)&lt;/li&gt;
&lt;li&gt;If you would like to export as Android App Bundle (.aab)&lt;/li&gt;
&lt;li&gt;Build on every push or manually&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Build number
&lt;/h4&gt;

&lt;p&gt;You can setup if you would like to automatically increase the Build number.&lt;/p&gt;

&lt;h4&gt;
  
  
  Testing and linting
&lt;/h4&gt;

&lt;p&gt;Run unit tests (runs &lt;code&gt;yarn test&lt;/code&gt;)&lt;br&gt;
Run linting (runs &lt;code&gt;yarn lint&lt;/code&gt;).&lt;/p&gt;
&lt;h4&gt;
  
  
  Environment variables
&lt;/h4&gt;

&lt;p&gt;You can setup Environment variables for this specific build. Really convenient if you are using keys or specific URL's that your app should use. You can also setup different URL's for different branches if you would like to build an app towards an development server as an example.&lt;br&gt;
If you need to consume these variables, I would recommend to create an Build Script that reads them and creates an .env file. You would read these variables from the .env file with &lt;a href="https://github.com/zetachang/react-native-dotenv"&gt;react-native-dotenv&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Example build script that outputs API_URL from Environment variables into an .env-file that you can put in your project root as appcenter-post-clone.sh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash -e&lt;/span&gt;

&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="nv"&gt;$APPCENTER_SOURCE_DIRECTORY&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"API_URL=&lt;/span&gt;&lt;span class="nv"&gt;$API_URL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .env
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;".env file created!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"API_URL=&lt;/span&gt;&lt;span class="nv"&gt;$API_URL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Sign your build
&lt;/h4&gt;

&lt;p&gt;If you want to run your app on a device you need to sign it.&lt;br&gt;
For iOS you need to upload a provisioning profile and a certificate.&lt;br&gt;
Both are created via Apple Developer portal an to create an certificate you need MacOS with Keychain.&lt;br&gt;
For Android you will generate a keystore file that you need to upload.&lt;/p&gt;

&lt;h4&gt;
  
  
  Test on real device
&lt;/h4&gt;

&lt;p&gt;You can, for free, test starting up your app on real device. App Center has a large amount of devices that can be used for device testing but this on is kinda only a small taste of that.&lt;/p&gt;

&lt;h4&gt;
  
  
  Distribute builds
&lt;/h4&gt;

&lt;p&gt;Last you can select if you want to automatically distribute your build. More on distribution under.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dw-Vs0Ra--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ovel1yr6j6l8gpffvwgd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dw-Vs0Ra--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ovel1yr6j6l8gpffvwgd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
App Center can also be used to test your apps on a large number of real devices.&lt;br&gt;
From your build config you can add a "does app start" test on device.&lt;/p&gt;

&lt;p&gt;To run additional tests on the devices you need to run a test framework. Available frameworks for running tests are currently Appium, Calabash, XCUITest (only iOS), Espresso (only Android) and Xamarin.UITest.&lt;/p&gt;

&lt;p&gt;There have been discussions from App Center to add more available test frameworks. For React Native, Detox would be a really nice addition.&lt;/p&gt;

&lt;h3&gt;
  
  
  Distribute to App Center Groups
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CSbApy8d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b45qu34xknkkwq6f5ula.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CSbApy8d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b45qu34xknkkwq6f5ula.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When your app builds it's time to start distribute it to testers. A great way to do this without needing to setup the app in the stores for iOS and Android is to use App Center Groups distribution.&lt;/p&gt;

&lt;p&gt;For Android the .apk-file is distributed and a link will be sent to the users in your testing group.&lt;/p&gt;

&lt;p&gt;For iOS, when users recieve the invite email, they will first share their device ID with App Center. Then the app will be re-provisioned to work with that device and the .ipa-file will be shared. This requires a development or ad hod distribution profile for the app.&lt;/p&gt;

&lt;p&gt;From within App Center you can manage multiple groups and distribute different releases to different groups.&lt;/p&gt;

&lt;h3&gt;
  
  
  Distribute to stores
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mdRRgTjz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y30ugpe6qc38oxzv0ezk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mdRRgTjz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y30ugpe6qc38oxzv0ezk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Distribute Android apps to Play Store&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B7rX5kR8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ue75zd4j7cuejzwgv2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B7rX5kR8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ue75zd4j7cuejzwgv2h.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Distribute iOS apps to App Store and Test Flight&lt;/p&gt;

&lt;p&gt;You can setup to automatically distribute your apps to both App Store (and Test Flight for iOS beta testing) and Play Store.&lt;/p&gt;

&lt;p&gt;Notice that for both iOS and Android you need to first create your apps in App Store Connect and Play Console and upload your first app before you can do it from App Center.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Push
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ax32MDYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yeu7z6oiclq7fvr5yo1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ax32MDYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yeu7z6oiclq7fvr5yo1v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A really neat feature in App Center is Code Push. When you have built and released your app, you can "push" your JavaScript bundle to the app.&lt;/p&gt;

&lt;p&gt;As long as your updates are "just" JavaScript updates (no updates with native modules) you can send those updates to all users. Each time a user opens your app it will check if the app has an Code Push update. If it has an update it will download. You can then decide if you would like you app to instantly update (by restarting) or if the app should update the next time the user starts your app.&lt;/p&gt;

&lt;p&gt;This way you can "bypass" the app stores process of approving you app which can take some hours up to a day or two.&lt;/p&gt;

&lt;p&gt;Notice, each Code Push will be "connected" to a specific version of your app. And all new app downloads will NOT contain your update. So you would problably also want to release a new app version with your fixes together with your code push.&lt;/p&gt;

&lt;h3&gt;
  
  
  Crash reports
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wo3Iup62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rjw6n4rofboxttg7fzoh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wo3Iup62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rjw6n4rofboxttg7fzoh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When adding &lt;code&gt;appcenter-crashes&lt;/code&gt; you will also make sure that all app crashes will be sent to App Center. You can see an overview of crashes and have App Center send you emails with information&lt;/p&gt;

&lt;h3&gt;
  
  
  Analytics
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KyiU5eT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mifetxr9vmdftakvyx6n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KyiU5eT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mifetxr9vmdftakvyx6n.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will also get a basic analytics of your app. You'll see information about uses, devices, location and devices used. You can also add custom events from your app and follow how your users uses your app.&lt;/p&gt;

&lt;p&gt;Analytics are saved for 90 days. If you would like to save if it longer you can export it to Azure Application Insight. This is a much more powerful tool but also costs by usage.&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>appcenter</category>
    </item>
    <item>
      <title>Build an React Native app. Part 1: Development</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Wed, 19 Feb 2020 19:00:43 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/build-an-react-native-app-part-1-development-250d</link>
      <guid>https://dev.to/andreasbergqvist/build-an-react-native-app-part-1-development-250d</guid>
      <description>&lt;p&gt;At &lt;a href="https://www.itiden.se"&gt;Itiden&lt;/a&gt; we build web applications and mobile apps.&lt;br&gt;
For both we really enjoy using React &amp;amp; React Native.&lt;/p&gt;

&lt;p&gt;This blog post is a informational post to my talk at React meetup in Gothenburg in two parts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build an React Native app. Part 1: Development (this)&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://dev.to/andreasbergqvist/build-an-react-native-app-part-2-distribution-2ddl"&gt;Build an React Native app. Part 2: Distribution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have open sourced an React Native app called "Guess the Repo" that uses the libraries we have decided on. It's a quiz app with questions about Github repos. Read more about the app on &lt;a href="https://guesstherepo.itiden.se"&gt;https://guesstherepo.itiden.se&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's not in anyway a spectacular app. But it's quite easy to get up and running if you would like to see how an React Native app can be done.&lt;/p&gt;
&lt;h2&gt;
  
  
  Development
&lt;/h2&gt;

&lt;p&gt;This is a general overview of how we have decided to use React Native and what libraries we use. Generally we have settled with what we think is &lt;strong&gt;enjoyable&lt;/strong&gt;, &lt;strong&gt;effective&lt;/strong&gt; and what seems to be well &lt;strong&gt;maintained&lt;/strong&gt;, &lt;strong&gt;documented&lt;/strong&gt; and &lt;strong&gt;updated&lt;/strong&gt; by the community.&lt;/p&gt;
&lt;h3&gt;
  
  
  React Native cli
&lt;/h3&gt;

&lt;p&gt;While there are other alternatives then using the React Native cli to initialize you new project. We have currently decided to use it for our projects.&lt;/p&gt;

&lt;p&gt;We are also using TypeScript and unlike a few years ago, it's really enjoyable to use with React Native apps.&lt;/p&gt;

&lt;p&gt;Code to initialize your new app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx react-native init GuessTheRepo --template react-native-template-typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  State management
&lt;/h3&gt;

&lt;p&gt;For global state management we have decided on MobX. It's really efficient and makes your code really easy to read and to follow.&lt;/p&gt;

&lt;p&gt;Add to your project with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add mobx
         mobx-react
         mobx-persist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that we add both mobx and mobx-react but also mobx-persist. It's an really convenient library to use if you like to keep some of your state persisted between app restarts.&lt;/p&gt;

&lt;p&gt;Example store:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;observable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mobx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;persist&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mobx-persist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;QuizStore&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;persist&lt;/span&gt;
  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;observable&lt;/span&gt;
  &lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;action&lt;/span&gt;
  &lt;span class="nx"&gt;addScore&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a store with a &lt;code&gt;score&lt;/code&gt; value that will be persisted. We also add an &lt;code&gt;addScore&lt;/code&gt; action to add 1 to the score.&lt;/p&gt;

&lt;p&gt;When you create the store, add the following code to make it use &lt;a href="https://github.com/react-native-community/async-storage"&gt;AsyncStorage&lt;/a&gt; as peristing storage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mobx-persist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;quizStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;QuizStore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hydrate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AsyncStorage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="na"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;hydrate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;quizStore&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;quizStore&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the score value will be kept even if the app is closed.&lt;br&gt;
To use the score value or use the action method from an component, see the following code (notice that we created the store in an Context that we can get from a useQuizStore() function):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mobx-react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;useQuizStore&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../context/AppContext&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;QuizScreen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;quizStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useQuizStore&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Score &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;quizStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;onPress&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;quizStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addScore&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Button&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;QuizScreen&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to "wrap" your component in the &lt;code&gt;observer&lt;/code&gt; function (HoC) to make sure the component re-renders when an value from the MobX store updates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Styling
&lt;/h3&gt;

&lt;p&gt;When it comes to styling we have decided on &lt;a href="https://styled-components.com/"&gt;styled-components&lt;/a&gt;. It's enjoyable, efficient and creates really readable code. And it works really well for both React and React Native.&lt;/p&gt;

&lt;p&gt;Add it to your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add styled-components
         @types/styled-components
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that the TypeScript typings needs to be fetched from the @types repo.&lt;/p&gt;

&lt;p&gt;When using styled-components with React Native you need to use the /native library.&lt;/p&gt;

&lt;p&gt;Example on using it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;styled-components/native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Background&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TouchableOpacity&lt;/span&gt;&lt;span class="s2"&gt;`
  border-radius: 20px;
  background-color: #000000;
  padding: 10px 20px;
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="s2"&gt;`
  font-size: 24px;
  color: #fff;
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;onPress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ButtonProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Background&lt;/span&gt;
    &lt;span class="na"&gt;onPress&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onPress&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;       
  &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Label&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Background&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Navigation
&lt;/h3&gt;

&lt;p&gt;For navigation react-navigation has come a real long way since v1. Now at version 5 we have a completely new declarative way of declaring our navigation routes.&lt;/p&gt;

&lt;p&gt;First, a bunch of libraries are needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @react-navigation/native
         @react-navigation/stack
         react-native-gesture-handler
         react-native-reanimated
         react-native-screens
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All of these are not needed, but the @react-navigation/stack is commonly used navigation type. And react-native-gesture-handler and react-native-reanimated dependencies needed for performant animations and gestures. The react-native-screens make even more use of native views when the different routes are created making it even more performant.&lt;/p&gt;

&lt;p&gt;Read more on getting started with React Navigation on their &lt;a href="https://reactnavigation.org/docs/en/getting-started.html"&gt;docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Example of setting up your routes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;NavigationContainer&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@react-navigation/native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;createStackNavigator&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@react-navigation/stack&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;HomeScreen&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./screens/Home&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;QuizScreen&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./screens/Quiz&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createStackNavigator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;NavigationContainer&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Navigator&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Screen&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Home"&lt;/span&gt; &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;HomeScreen&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Screen&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Quiz"&lt;/span&gt; &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;QuizScreen&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Navigator&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;NavigationContainer&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Routes&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When creating components you can now do the following to link to other routes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;useNavigation&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@react-navigation/native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HomeScreen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useNavigation&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Navigate!"&lt;/span&gt; &lt;span class="na"&gt;onPress&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Quiz&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;HomeScreen&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are some of the "building blocks" used to create an React Native app.&lt;/p&gt;

&lt;p&gt;Next up I'll show how you can distribute your app with App Center from Microsoft. &lt;br&gt;
&lt;a href="https://dev.to/andreasbergqvist/build-an-react-native-app-part-2-distribution-2ddl"&gt;Build an React Native app. Part 2: Distribution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For some more inspration, check out William Candillon's "Can it be done in React Native?" youtube channel! &lt;a href="https://www.youtube.com/channel/UC806fwFWpiLQV5y-qifzHnA"&gt;https://www.youtube.com/channel/UC806fwFWpiLQV5y-qifzHnA&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>appcenter</category>
    </item>
    <item>
      <title>Web development on Windows using WSL 2</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Mon, 02 Sep 2019 20:28:17 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/web-development-on-windows-using-wsl-2-5207</link>
      <guid>https://dev.to/andreasbergqvist/web-development-on-windows-using-wsl-2-5207</guid>
      <description>&lt;p&gt;So, I've been testing the new WSL 2 (Windows Subsystem for Linux 2).&lt;br&gt;
It's currently available when using Windows 10 Insider Preview Build.&lt;br&gt;
This means that you needs to setup your Windows 10 system to install preview builds.&lt;br&gt;
&lt;em&gt;Install at own risk :-)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Information on how to install WSL 2 is found here:&lt;br&gt;
&lt;a href="https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/" rel="noopener noreferrer"&gt;https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This version of WSL could be considered more of an complete Linux environment. Like an Virtual Machine running on your Windows computer. But of course speedy, lightweight and more integrated with Windows. I'm not an expert on architecture but there are other articles you can find regarding this =)&lt;/p&gt;

&lt;p&gt;I'm just looking for a smooth developer experience on Windows (yeah, I'm a web developer you prefers Windows... Strange...).&lt;/p&gt;
&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;So, you basically have a bare Linux installation now (I installed Ubuntu 18.04).&lt;br&gt;
So if you want to run Node, PHP or other application you need to install the appropriate packages. There are a number of guides how to do that.&lt;/p&gt;

&lt;p&gt;You know:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install this
sudo apt install that
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The new Windows terminal
&lt;/h3&gt;

&lt;p&gt;I'm also using the new Windows terminal. This one is found (also as a Preview) in the Windows Store.&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%2F5neejb36qxyeypzlod8x.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%2F5neejb36qxyeypzlod8x.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During the time I've used it there have been some updates and I would generally say I like it. Great addition to the developer experience in Windows.&lt;/p&gt;

&lt;p&gt;Here, I create a Next.js project:&lt;br&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%2Fz6x6pfk8290uih6jgqve.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%2Fz6x6pfk8290uih6jgqve.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Integration with VS Code
&lt;/h3&gt;

&lt;p&gt;Install the "Remote - WSL" VS Code extension:&lt;br&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, from VS Code command palette (CTRL+Shift+P) run "Remote-WSL: New Window"&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%2Fp2c5n81o2znw341hk85p.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%2Fp2c5n81o2znw341hk85p.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, when you select "Open folder" you can select from your WSL dist:&lt;br&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%2F62hzj8cfr1aj169miu2q.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%2F62hzj8cfr1aj169miu2q.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now access and edit the files directly and use the terminal:&lt;br&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%2Fz5vy0wdykoar5sw0ohje.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%2Fz5vy0wdykoar5sw0ohje.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And even if the Linux distibution has it's own IP address, you can reach it through localhost:&lt;br&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%2Fz16rio8aoo6z4ndwvzkf.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%2Fz16rio8aoo6z4ndwvzkf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Lets test an Laravel project (PHP)
&lt;/h3&gt;

&lt;p&gt;First, make sure you have PHP-FMP and Composer installed.&lt;/p&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer global require laravel/installer
laravel new blog
cd blog
php artisan serve --host=0.0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;--host=0.0.0.0&lt;/code&gt;. This was the only way I got the localhost:8000 to work in the browser:&lt;br&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%2F3egyyll9tv9jxnmbd9op.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%2F3egyyll9tv9jxnmbd9op.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Whats missing?
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Auto-starting services
&lt;/h4&gt;

&lt;p&gt;The services you install (like PHP-FPM or MySQL) need to be started manually after every system restart. I read about third-party solutions that might fix it but I would rather have it integrated in WSL.&lt;/p&gt;

&lt;h4&gt;
  
  
  Custom hostnames
&lt;/h4&gt;

&lt;p&gt;I like to name my different sites stuff like thesitename.local and access them that way. It's possible, but since the WSL system changes IP address after every restart, the hosts-file need to be manually updated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Future and Docker
&lt;/h3&gt;

&lt;p&gt;Docker for Windows has announced that it will support running via WSL. There is currently a Tech Previews that I haven't yet tested. But that seems really cool!&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;During the time I tested it most things seems to work just fine and with some more fixes I would say that web developing on Windows has a bright future used with WSL 2.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>windows</category>
      <category>wsl</category>
    </item>
    <item>
      <title>Static site with Next.js, Contentful &amp; Netlify</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Wed, 03 Jul 2019 20:41:26 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/static-site-with-next-js-contentful-netlify-1h7e</link>
      <guid>https://dev.to/andreasbergqvist/static-site-with-next-js-contentful-netlify-1h7e</guid>
      <description>&lt;h3&gt;
  
  
  TL;DR
&lt;/h3&gt;

&lt;p&gt;Code: &lt;a href="https://github.com/itiden/itiden.se/tree/blog" rel="noopener noreferrer"&gt;https://github.com/itiden/itiden.se/tree/blog&lt;/a&gt; (blog branch)&lt;br&gt;
Result: &lt;a href="https://itiden.se" rel="noopener noreferrer"&gt;https://itiden.se&lt;/a&gt; (yeah, it's in Swedish, sorry...)&lt;/p&gt;

&lt;p&gt;Edit 2020-02-17:&lt;br&gt;
The webpage has been updated. It no longer use as much of Contentful as before. Check out the blog bransch for the code referenced in this blog posts.&lt;/p&gt;
&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;This is a guide to copy our open sourced website. You will be able to setup Contentful with some dummy content. But make sure you see it as a template for your site. To be able to edit the site knowledge about Next.js / React is required.&lt;/p&gt;

&lt;p&gt;Feel free to ask any questions but the idea is to make it easy for you to test Contentful hosted on Netlify with a site developed in React.&lt;/p&gt;
&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;p&gt;So, at itiden we wanted a site where we would use Contentful as a "cloud CMS" and to host it on Netlify.&lt;/p&gt;

&lt;p&gt;Since we have previous experience with Next.js (React) we decided to use it when building the page.&lt;/p&gt;

&lt;p&gt;It's written in Typescript and we are using Tailwind as a "CSS framework" with Styled Components as the "CSS in JS" library.&lt;/p&gt;

&lt;p&gt;The code is open sourced on Github (&lt;a href="https://github.com/itiden/itiden.se" rel="noopener noreferrer"&gt;https://github.com/itiden/itiden.se&lt;/a&gt;) and you can feel free to clone it and use it as a template for your own website&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup the project
&lt;/h2&gt;

&lt;p&gt;Start by creating you own copy of the repo by clicking "Use this template" button on &lt;a href="https://github.com/itiden/itiden.se" rel="noopener noreferrer"&gt;https://github.com/itiden/itiden.se&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you have your repo, clone it and copy the .env.example to .env and run yarn.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp .env.example .env
yarn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you need to setup Contentful to be able to fetch some content.&lt;br&gt;
Create a new account if you don't have one already. After that you will need to create a empty space.&lt;/p&gt;

&lt;p&gt;Your should now be on a screen where you are asked to add your first content type.&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%2Fhvquuwq7qzgvad2p8h19.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%2Fhvquuwq7qzgvad2p8h19.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When your at that screen, install Contentful CLI by running &lt;code&gt;npm install -g contentful-cli&lt;/code&gt;.&lt;br&gt;
Start by logging it to your account by running &lt;code&gt;contentful login&lt;/code&gt;.&lt;br&gt;
If successful you will receive a token that will be saved on your computer.&lt;/p&gt;

&lt;p&gt;Now you need to import some content types and content. There is a &lt;code&gt;contentful-export.json&lt;/code&gt; file in the repo.&lt;/p&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;code&gt;contentful space import --space-id &amp;lt;your space id&amp;gt; --content-file contentful-export.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can find your space id in the URL on contentful:&lt;br&gt;
&lt;a href="https://app.contentful.com/spaces/space_id/home" rel="noopener noreferrer"&gt;https://app.contentful.com/spaces/space_id/home&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now reload the contentful page and click the "Use the Api" button.&lt;br&gt;
On this page, copy the space id and Content Delivery API - access token to your .env file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTENTFUL_SPACE=&amp;lt;space id&amp;gt;
CONTENTFUL_TOKEN=&amp;lt;access token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now run &lt;code&gt;yarn getcontent&lt;/code&gt; to fetch the content from Contenful and then &lt;code&gt;yarn dev&lt;/code&gt; to start your development server.&lt;/p&gt;

&lt;p&gt;Goto &lt;a href="http://localhost:3000/" rel="noopener noreferrer"&gt;http://localhost:3000/&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Content models
&lt;/h2&gt;

&lt;p&gt;Read about Content Models here:&lt;br&gt;
&lt;a href="https://www.contentful.com/r/knowledgebase/content-modelling-basics/" rel="noopener noreferrer"&gt;https://www.contentful.com/r/knowledgebase/content-modelling-basics/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following Contentful Content models have now been created in your space. The explanations are for how we are using them, but its up to you to use them like you want. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Menu&lt;/strong&gt;&lt;br&gt;
Currently there is only one Menu entry and that is the main top Menu.&lt;br&gt;
The main menu contains &lt;strong&gt;Menu Item&lt;/strong&gt;. Notice, the first menu item, named "Case" does not have an Menu Item. It is hard-coded in the front-end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Menu Item&lt;/strong&gt;&lt;br&gt;
A menu item have a Label and a reference to a &lt;strong&gt;Page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Page&lt;/strong&gt;&lt;br&gt;
A page has a Title, Slug (used for generating the URL), Description, Header and Body. Header and Body are "Rich text" field where you can add Entries. Currently the only Entry that will be rendered in the front-end is the &lt;strong&gt;Employee&lt;/strong&gt; content model. Notice: the first page / is hard coded to display &lt;strong&gt;Case&lt;/strong&gt; content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Employee&lt;/strong&gt;&lt;br&gt;
These contents can be added to the Body field of an &lt;strong&gt;Page&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case&lt;/strong&gt;&lt;br&gt;
Case content is listed on the first page. They also receive the url /case/.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Category&lt;/strong&gt; / &lt;strong&gt;Technology&lt;/strong&gt; / &lt;strong&gt;Partner&lt;/strong&gt;&lt;br&gt;
These are all content that is added to a &lt;strong&gt;Case&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building static files
&lt;/h2&gt;

&lt;p&gt;The config for what pages that should be exported to static pages exists in the &lt;code&gt;next.config.js&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;See:&lt;br&gt;
&lt;a href="https://github.com/itiden/itiden.se/blob/353817c013092470b4548603fa3114aa55e69093/next.config.js#L14" rel="noopener noreferrer"&gt;https://github.com/itiden/itiden.se/blob/353817c013092470b4548603fa3114aa55e69093/next.config.js#L14&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To create the static files, run &lt;code&gt;yarn build&lt;/code&gt;.&lt;br&gt;
All created files will be exported to an &lt;code&gt;out&lt;/code&gt; folder.&lt;/p&gt;
&lt;h2&gt;
  
  
  Netlify hosting
&lt;/h2&gt;

&lt;p&gt;Create a account on Netlify if needed. Then start a new site based on your github repo.&lt;/p&gt;

&lt;p&gt;When asked, set "Build command" to &lt;code&gt;yarn build&lt;/code&gt; and "Output directory" to &lt;code&gt;out&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Go to Settings / Build &amp;amp; deploy / Environment.&lt;/p&gt;

&lt;p&gt;Edit Environment and add the rows from your .env file.&lt;br&gt;
CONTENTFUL_SPACE=&lt;br&gt;
CONTENTFUL_TOKEN=&lt;/p&gt;

&lt;p&gt;Go to Deploys and Trigger deploy.&lt;/p&gt;

&lt;p&gt;You have now received an Netlify URL for your site. Something like &lt;a href="https://strange_text.netlify.com/" rel="noopener noreferrer"&gt;https://strange_text.netlify.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next step will probably be to setup &lt;a href="https://www.netlify.com/docs/custom-domains/" rel="noopener noreferrer"&gt;Custom Domains&lt;/a&gt; and &lt;a href="https://www.netlify.com/docs/ssl/" rel="noopener noreferrer"&gt;HTTPS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You now have a statically created serverless hosted React site!&lt;/p&gt;
&lt;h2&gt;
  
  
  Trigger Rebuilds from Contenful
&lt;/h2&gt;

&lt;p&gt;In the top menu on Contenful, click Apps.&lt;br&gt;
Install Netlify app and connect your account.&lt;br&gt;
Then select the site you created.&lt;/p&gt;

&lt;p&gt;When editing your content, your now have a "Build" button and an "Open preview" button to build your site on Netlify.&lt;/p&gt;
&lt;h2&gt;
  
  
  Google Analytics
&lt;/h2&gt;

&lt;p&gt;To add Google Analytics, just add your tracking ID to your .env and/or your Environment variables on Netlify.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CONTENTFUL_SPACE=&amp;lt;space id&amp;gt;
CONTENTFUL_TOKEN=&amp;lt;access token&amp;gt;
GA=&amp;lt;tracking ID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>static</category>
      <category>contentful</category>
      <category>netlify</category>
    </item>
    <item>
      <title>Building an React Native movies quiz app</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Tue, 25 Jun 2019 08:24:35 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/building-an-react-native-app-2c9c</link>
      <guid>https://dev.to/andreasbergqvist/building-an-react-native-app-2c9c</guid>
      <description>&lt;p&gt;UPDATE 2019-06-27&lt;br&gt;
The app is released! Check it out on &lt;a href="https://ilovemoviez.com"&gt;https://ilovemoviez.com&lt;/a&gt;&lt;br&gt;
Still, feel free to ask us anything regarding the development!&lt;/p&gt;

&lt;p&gt;Today, at itiden (&lt;a href="http://www.itiden.se"&gt;www.itiden.se&lt;/a&gt;) we are taking all (about 10) developers to together build app React Native app.&lt;/p&gt;

&lt;p&gt;Hopefully we will be able to post it to the stores last thing today, but of course, the Apple process might take a while.&lt;/p&gt;

&lt;p&gt;It's an online movies quiz app called I Love Moviez.&lt;/p&gt;

&lt;p&gt;The back-end is being built with Node.js using Adonis.js.&lt;br&gt;
For the React Native app we are using Typescript, React Navigation, Mobx and Styled Components. Deployed with Microsoft App Center.&lt;/p&gt;

&lt;p&gt;Feel free to ask anything during the day!&lt;/p&gt;

&lt;p&gt;We will also post updates to:&lt;br&gt;
&lt;a href="https://twitter.com/ilovemoviez"&gt;https://twitter.com/ilovemoviez&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ama</category>
      <category>react</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>React Navigation with Typescript</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Tue, 14 May 2019 11:57:05 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/react-navigation-with-typescript-29ka</link>
      <guid>https://dev.to/andreasbergqvist/react-navigation-with-typescript-29ka</guid>
      <description>&lt;p&gt;So.. You want to build an React Native app with Typescript and you have decided to use React Navigation as navigation library.&lt;/p&gt;

&lt;p&gt;You have set all the Typescript stuff up and gets your app running!&lt;/p&gt;

&lt;p&gt;You add React Navigation and all is fine!&lt;/p&gt;

&lt;p&gt;But.. You add some screens that expects parameters and some that you want to edit the header and so on. There is not much information to find...&lt;/p&gt;

&lt;p&gt;Here are some snippets how I have used React Navigation with Typescript.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;Disclaimer&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;There are multiple ways of implementing typed React Navigation. These are only some examples and the naming of things should be considered to fit your application.&lt;/p&gt;

&lt;p&gt;Any comments of other ways to solve it is appreciated!&lt;/p&gt;

&lt;h2&gt;
  
  
  First, classes vs functions...
&lt;/h2&gt;

&lt;p&gt;I really enjoy using function components with hooks.&lt;br&gt;
But currently there is an issue with hot reloading if using function components.&lt;br&gt;
See: &lt;a href="https://github.com/facebook/react-native/issues/10991"&gt;https://github.com/facebook/react-native/issues/10991&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It just don't work. There might be solutions where you wrap you functional components around with classes, but hopefully this issue will soon be fixed!&lt;br&gt;
&lt;a href="https://mobile.twitter.com/dan_abramov/status/1125846420949434368"&gt;https://mobile.twitter.com/dan_abramov/status/1125846420949434368&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will be using a useNavigation hook based of &lt;a href="https://github.com/react-navigation/hooks"&gt;https://github.com/react-navigation/hooks&lt;/a&gt;.&lt;br&gt;
But since the repo isn't very active, I just "stole" this function and modified abit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationRoute&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-navigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;useNavigation&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Params&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;NavigationContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
    &lt;span class="nx"&gt;NavigationRoute&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;Params&lt;/span&gt;
  &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, my examples will be with both classes and functional components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update header title and navigate
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Class component
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationParams&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-navigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavigationState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NavigationParams&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TestScreen&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Props&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;navigationOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Test Screen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Test&lt;/span&gt; &lt;span class="nx"&gt;Screen&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt;
          &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;onPress&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anotherTestScreen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="p"&gt;}}&lt;/span&gt;
        &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;TestScreen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice, that only screens that is set up directly on a navigation has the navigation property. If you would like a sub-component to have access to navigation you can do like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NavigationInjectedProps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;withNavigation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-navigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TestComponent&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavigationInjectedProps&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt;
        &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onPress&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anotherTestScreen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}}&lt;/span&gt;
      &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;withNavigation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;TestComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Function component
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useNavigation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../hooks/useNavigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AnotherTestScreen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useNavigation&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Test&lt;/span&gt; &lt;span class="nx"&gt;Screen&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt;
        &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onPress&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paramScreen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hi!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
        &lt;span class="p"&gt;}}&lt;/span&gt;
      &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;AnotherTestScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;navigationOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Another Test Screen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AnotherTestScreen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Typed params for the screens
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Class component
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NavigationState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-navigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;NavigationParams&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Navigation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavigationState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NavigationParams&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Navigation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ParamScreen&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Props&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;navigationOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Navigation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Param&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt;
          &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;onPress&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;anotherParamScreen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
          &lt;span class="p"&gt;}}&lt;/span&gt;
        &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;ParamScreen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why would you bother with that much extra typings code you might ask yourself? Why not just use &lt;code&gt;any&lt;/code&gt;? &lt;br&gt;
Well, this example might not be the best, but the params are now typed and you can get intellisense help in your editor:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0erlacquxymcve0s69r5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0erlacquxymcve0s69r5.png" width="626" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Function component
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;View&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;StackActions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NavigationActions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-navigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useNavigation&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../hooks/useNavigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;NavigationParams&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Navigation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;NavigationScreenProp&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavigationState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;NavigationParams&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AnotherParamScreen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useNavigation&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;NavigationParams&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;View&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Text&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Param&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Text&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Button&lt;/span&gt;
        &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;onPress&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resetAction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;StackActions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
            &lt;span class="na"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;actions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;NavigationActions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;navigate&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;routeName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;testScreen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})],&lt;/span&gt;
          &lt;span class="p"&gt;});&lt;/span&gt;
          &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resetAction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}}&lt;/span&gt;
      &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/View&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;AnotherParamScreen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;navigationOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Navigation&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;navigation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;AnotherParamScreen&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



</description>
      <category>react</category>
      <category>reactnative</category>
      <category>reactnavigation</category>
      <category>typescript</category>
    </item>
    <item>
      <title>npx, at you command</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Tue, 16 Apr 2019 05:42:15 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/npx-at-you-command-lfd</link>
      <guid>https://dev.to/andreasbergqvist/npx-at-you-command-lfd</guid>
      <description>&lt;p&gt;Since version 5.2 of npm (released almost 2 years ago) you also received the command &lt;code&gt;npx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;npx&lt;/code&gt; you can run the binaries for your project dependencies (like &lt;code&gt;npx webpack&lt;/code&gt; or &lt;code&gt;npx jest&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;But you can also run any command from any package available on npm!&lt;br&gt;
Here are some of my favorites!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx http-server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Starts a webserver in the current folder. Great if you want to test something really quick.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use create-react-app without the need to first install it globally. Just run &lt;code&gt;npx&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx shx &lt;span class="nb"&gt;touch &lt;/span&gt;file &lt;span class="c"&gt;# Create a file&lt;/span&gt;
npx shx &lt;span class="nb"&gt;mkdir &lt;/span&gt;folder &lt;span class="c"&gt;# Create a folder&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;shx&lt;/code&gt; command lets you run shell commands, cross-platform! Great if you want to share command snippets that both Mac and Windows users might use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx sort-package-json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Sorts the keys in your package.json (if there is a package.json in the current directory).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx speed-test
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Test your internet connection&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx typescript index.ts &lt;span class="nt"&gt;--out&lt;/span&gt; index.js
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you want to check the result when TypeScript transforms a .ts file to a .js.&lt;br&gt;
Notice, this is probably for more simple files and mostly if you want to investigate how it works, since you don't use an config file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx terser index.js &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; index.min.js
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Minify a Javascript file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx ntl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Gives you an interactive list of available NPM scripts (if you are in a folder with an package.json).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx puppeteer-cli print https://itiden.se page.pdf
npx puppeteer-cli screenshot https://itiden.se page.png
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Create an PDF or screenshot from an URL. Notice that Chromium is downloaded when this command i run which makes it quite slow. But might come in handy if you quickly want an PDF or screenshot of an webpage!&lt;/p&gt;

&lt;p&gt;And, if you'd like, you can set up your own "card" to display in the terminal. See:&lt;br&gt;
&lt;a href="https://dev.to/wuz/setting-up-a-npx-username-card-1pip"&gt;https://dev.to/wuz/setting-up-a-npx-username-card-1pip&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npx andreasbergqvist
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Feel free to comment on more commands that might come in handy!&lt;/p&gt;

</description>
      <category>node</category>
      <category>npx</category>
      <category>javascript</category>
    </item>
    <item>
      <title>TypeScript - get types from data using typeof</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Wed, 10 Apr 2019 07:49:54 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/typescript-get-types-from-data-using-typeof-4b9c</link>
      <guid>https://dev.to/andreasbergqvist/typescript-get-types-from-data-using-typeof-4b9c</guid>
      <description>&lt;p&gt;A great way to make sure the values you set to your variables matches what you would expect is to set specific types to them.&lt;/p&gt;

&lt;p&gt;If you already have the data in a object or array. The following ways are great to create your types!&lt;/p&gt;

&lt;p&gt;Lets say you have the following data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then you can create a type bases on that using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// type Data = {&lt;/span&gt;
&lt;span class="c1"&gt;//   value: number;&lt;/span&gt;
&lt;span class="c1"&gt;//   text: string;&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can do the same with nested objects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;subData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// type Data = {&lt;/span&gt;
&lt;span class="c1"&gt;//   value: number;&lt;/span&gt;
&lt;span class="c1"&gt;//   text: string;&lt;/span&gt;
&lt;span class="c1"&gt;//   subData: {&lt;/span&gt;
&lt;span class="c1"&gt;//     value: boolean;&lt;/span&gt;
&lt;span class="c1"&gt;//   };&lt;/span&gt;
&lt;span class="c1"&gt;// }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Since TypeScript 3.4 you can do the following if you have an array of strings (notice the &lt;code&gt;as const&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="c1"&gt;// type Data = "text 1" | "text 2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's also possible to get types from arrays with objects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;locales&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;se&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;language&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Swedish&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;en&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;language&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;English&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Locale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;locales&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;locale&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="c1"&gt;// type Locale = "se" | "en"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And it's also possible to get types from keys:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currencySymbols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;GBP&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;£&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;USD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;EUR&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;€&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CurrencySymbol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kr"&gt;keyof&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;currencySymbols&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// type CurrencySymbol = "GBP" | "USD" | "EUR"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A notice about &lt;code&gt;as const&lt;/code&gt; vs using &lt;code&gt;&amp;lt;const&amp;gt;&lt;/code&gt;. They both work the same but the &lt;code&gt;&amp;lt;const&amp;gt;&lt;/code&gt; will fail in a .tsx-file (React).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// is the same as&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>types</category>
    </item>
    <item>
      <title>React is awesome!</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Mon, 08 Apr 2019 21:56:37 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/react-is-awesome-ppd</link>
      <guid>https://dev.to/andreasbergqvist/react-is-awesome-ppd</guid>
      <description>&lt;p&gt;Just wanna say that creating stuff with React is so much fun!&lt;br&gt;
Hooks being an awesome addition!&lt;/p&gt;

&lt;p&gt;Currently the following libraries/packages/language-supersets is making it even more fun!&lt;/p&gt;

&lt;h3&gt;
  
  
  TypeScript
&lt;/h3&gt;

&lt;p&gt;Like 1-2 years ago, using TypeScript - especially with React (where more developers where using Flow), was like more trouble then what it was worth... Nowadays though, it makes a awesome developer experience and mst popular packages has typings available! Good job Microsoft!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Microsoft/TypeScript"&gt;https://github.com/Microsoft/TypeScript&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Mobx
&lt;/h3&gt;

&lt;p&gt;Since the day Mobx was released it's been my goto state handler. The main benefit for me is that it makes the code very readable and easy to understand.&lt;/p&gt;

&lt;p&gt;Nowadays, since hooks was released, the &lt;a href="https://github.com/mobxjs/mobx-react-lite"&gt;mobx-react-lite&lt;/a&gt; library is a great addition!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/mobxjs/mobx"&gt;https://github.com/mobxjs/mobx&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Styled Components
&lt;/h3&gt;

&lt;p&gt;I just love creating my styled components instead of using style-objects. Makes the render functions really nice and readable!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/styled-components/styled-components"&gt;https://github.com/styled-components/styled-components&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Formik
&lt;/h3&gt;

&lt;p&gt;Forms in React has been troublesome... But no more!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jaredpalmer/formik"&gt;https://github.com/jaredpalmer/formik&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Prettier / eslint
&lt;/h3&gt;

&lt;p&gt;I'm using prettier to format the code on save! Never do I need to think about how to format nor indent my code. Eslint is a great addition to warn me about other "bad code". Make sure they don't conflict with eachother with &lt;a href="https://github.com/prettier/eslint-config-prettier"&gt;eslint-config-prettier&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prettier/prettier"&gt;https://github.com/prettier/prettier&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/eslint/eslint"&gt;https://github.com/eslint/eslint&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  react-test-library
&lt;/h3&gt;

&lt;p&gt;If I where about to test my React code, I would be doing it with react-test-library 😂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kentcdodds/react-testing-library"&gt;https://github.com/kentcdodds/react-testing-library&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;end-of-react-love&amp;gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>mobx</category>
    </item>
    <item>
      <title>TypeScript - undefined vs null</title>
      <dc:creator>Andreas Bergqvist</dc:creator>
      <pubDate>Mon, 08 Apr 2019 06:16:55 +0000</pubDate>
      <link>https://dev.to/andreasbergqvist/typescript-undefined-vs-null-3a22</link>
      <guid>https://dev.to/andreasbergqvist/typescript-undefined-vs-null-3a22</guid>
      <description>&lt;p&gt;So the &lt;code&gt;undefined&lt;/code&gt; vs &lt;code&gt;null&lt;/code&gt; discussion might seem ancient in the JavaScript world. But for me, the question arises again the more I move over to TypeScript.&lt;/p&gt;

&lt;p&gt;There seems to be 3 different "camps" when I try to read posts regarding this...&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;I will try to NOT use &lt;code&gt;null&lt;/code&gt; and trying to only use &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I read enough comments from people that has done this and seems happy with it to give it a try.&lt;/p&gt;

&lt;p&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Easier" syntax &lt;code&gt;let variable?:Type;&lt;/code&gt; vs &lt;code&gt;let variable:Type = null&lt;/code&gt; or &lt;code&gt;let variable?:Type = null&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Most other languages seems to have just one type for this!&lt;/li&gt;
&lt;li&gt;Code does not need to handle both.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cons&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Longer to write&lt;/li&gt;
&lt;li&gt;The difference between an actually &lt;code&gt;undefined&lt;/code&gt; variable vs a variable set to &lt;code&gt;null&lt;/code&gt; is lost.&lt;/li&gt;
&lt;li&gt;JSON can only handle &lt;code&gt;null&lt;/code&gt; and not &lt;code&gt;undefined&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Camp 1 - use both
&lt;/h2&gt;

&lt;p&gt;So, an alternative could absolutely be to use both. And this is how I have donw previously.&lt;br&gt;
But, as mentioned in the TL;DR, most other languages seems to manage without both, and as a programmer, you might need to handle both undefined and null variables, which can make the code more complex.&lt;/p&gt;

&lt;p&gt;The pros are, as mentioned, that there now is a difference between an actually &lt;code&gt;undefined&lt;/code&gt; variable and one set to &lt;code&gt;null&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// value = number | null | undefined&lt;/span&gt;

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



&lt;h2&gt;
  
  
  Camp 2 - use &lt;code&gt;null&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;null&lt;/code&gt; is a word more used in other languages AND is shorter to write!&lt;br&gt;
Is also works nicely with JSON APIs.&lt;/p&gt;

&lt;p&gt;The extra code needed is well worth to be able to differentiate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// value = number | null&lt;/span&gt;

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



&lt;h2&gt;
  
  
  Camp 3 - use &lt;code&gt;undefined&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;There should be no need of two typed and &lt;code&gt;undefined&lt;/code&gt; is the default one when not setting a value.&lt;/p&gt;

&lt;p&gt;Array functions is JavaScript return undefined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="c1"&gt;// value = number | undefined&lt;/span&gt;

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



</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>react</category>
    </item>
  </channel>
</rss>
