Wednesday, August 21, 2019

Getting Started with React Native

With the ever-increasing popularity of smartphones, developers are looking into solutions for building mobile applications. For developers with a web background, frameworks such as Cordova and Ionic, React Native, NativeScript, and Flutter allow us to create mobile apps with languages we’re already familiar with: HTML, XML, CSS, and JavaScript.

In this guide, we’ll take a closer look at React Native. You’ll learn the absolute basics of getting started with it. Specifically, we’ll cover the following:

  • what is React Native
  • what is Expo
  • how to set up an React Native development environment
  • how to create an app with React Native

Prerequisites

This tutorial assumes that you’re coming from a web development background. The minimum requirement for you to be able to confidently follow this tutorial is to know HTML, CSS, and JavaScript. You should also know how to install software on your operating system and work with the command line. We’ll also be using some ES6 syntax, so it would help if you know basic ES6 syntax as well. Knowledge of React is helpful but not required.

What is React Native?

React Native is a framework for building apps that work on both Android and iOS. It allows you to create real native apps using JavaScript and React. This differs from frameworks like Cordova, where you use HTML to build the UI and it will just be displayed within the device’s integrated mobile browser (WebView). React Native has built in components which are compiled to native UI components, while your JavaScript code is executed through a virtual machine. This makes React Native more performant than Cordova.

Another advantage of React Native is its ability to access native device features. There are many plugins which you can use to access native device features, such as the camera and various device sensors. If you’re in need of a platform-specific feature that hasn’t been implemented yet, you can also build your own native modules — although that will require you to have considerable knowledge of the native platform you want to support (Java or Kotlin for Android, and Objective C or Swift for iOS).

If you’re coming here and you’re new to React, you might be wondering what it is. React is a JavaScript library for the Web for building user interfaces. If you’re familiar with MVC, it’s basically the View in MVC. React’s main purpose is to allow developers to build reusable UI components. Examples of these components include buttons, sliders, and cards. React Native took the idea of building reusable UI components and brought it into mobile app development.

What is Expo?

Before coming here, you might have heard of Expo. It’s even recommended in the official React Native docs, so you might be wondering what it is.

In simple terms, Expo allows you to build React Native apps without the initial headache that comes with setting up your development environment. It only requires you to have Node installed on your machine, and the Expo client app on your device or emulator.

But that’s just how Expo is initially sold. In reality, it’s much more than that. Expo is actually a platform that gives you access to tools, libraries and services for building Android and iOS apps faster with React Native. Expo comes with an SDK which includes most of the APIs you can ask for in a mobile app development platform:

Those are just few of the APIs you get access to out of the box if you start building React Native apps with Expo. Of course, these APIs are available to you as well via native modules if you develop your app using the standard React Native setup.

Plain React Native or Expo?

The real question is which one to pick up — React Native or Expo? There’s really no right or wrong answer. It all depends on the context and what your needs are at the moment. But I guess it’s safe to assume that you’re reading this tutorial because you want to quickly get started with React Native. So I’ll go ahead and recommend that you start out with Expo. It’s fast, simple, and easy to set up. You can dive right into tinkering with React Native code and get a feel of what it has to offer in just a couple of hours.

That said, I’ve still included the detailed setup instructions for standard React Native for those who want to do it the standard way. As you begin to grasp the different concepts, and as the need for different native features arises, you’ll actually find that Expo is kind of limiting. Yes, it has a lot of native features available, but not all the native modules that are available to standard React Native projects are supported.

Note: projects like unimodules are beginning to close the gap between standard React Native projects and Expo projects, as it allows developers to create native modules that works for both React Native and ExpoKit.

Setting Up the React Native Development Environment

In this section, we’ll set up the React Native development environment for all three major platforms: Windows, Linux, and macOS. We’ll also cover how to set up the Android and iOS simulators. Lastly, we’ll cover how to set up Expo. If you just want to quickly get started, I recommend that you scroll down to the “Setting up Expo” section.

Here are the general steps for setting up the environment. Be sure to match these general steps to the steps for each platform:

  1. install JDK
  2. install Android Studio or Xcode
  3. install Watchman
  4. update the environment variable
  5. install the emulator
  6. install Node
  7. install React Native CLI

You can skip to the section relevant to your operating system. Some steps — like setting up Android Studio — are basically the same for each operating system, so I’ve put them in their own section:

  • setting up on Windows
  • setting up on Linux
  • setting up on macOS
  • setting up Android Studio
  • install Node
  • setting up Expo
  • setting up emulators
  • install React Native CLI
  • troubleshooting common errors

Setting Up on Windows

This section will show you how to install and configure the software needed to create React Native apps on Windows. Windows 10 was used in testing for this.

Install Chocolatey

Windows doesn’t really come with its own package manager that we can use to install the needed tools. So the first thing we’ll do is install one called Chocolatey. You can install it by executing the following command on the command line or Windows Powershell:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

We can now install the other tools we need by simply using Chocolatey.

Install Python

Python comes with the command line tools required by React Native:

choco install -y python 2

Install JDK

The JDK allows your computer to understand and run Java code. Be sure to install JDK version 8 as that’s the one required by React Native:

choco install jdk8

Install NVM

Node has an installer for Windows. It’s better to use NVM for Windows, as that will enable you to install multiple versions of Node so that you can test new versions, or use a different version depending on the project you’re currently working on. For that, you can use NVM for Windows. Download nvm-setup.zip, extract it and execute nvm-setup.exe to install it.

Install Watchman

Watchman optimizes the compilation time of your React Native app. It’s an optional install if you’re not working on a large project. You can find the install instructions on their website.

Update the Environment Variables

This is the final step in setting up React Native on Windows. This is where we update the environment variables so the operating system is aware of all the tools required by React Native. Follow these steps right before you install the React Native CLI.

  1. Go to Control PanelSystem and SecuritySystem. Once there, click the Advanced system settings menu on the left.

    Windows advanced system settings

  2. That will open the system properties window. Click on the Environment Variables button:

    System properties

  3. Under the User variables section, highlight the Path variable and click the edit button.

  4. On the edit screen, click the New button and enter the path to the Android SDK and platform tools. For me, it’s on C:\users\myUsername\AppData\Local\Android\Sdk and C:\users\myUsername\AppData\Local\Android\Sdk\platform-tools. Note that this is also where you add the path to the JDK if it isn’t already added:

    add path

The post Getting Started with React Native appeared first on SitePoint.


by Wern Ancheta via SitePoint

How to market your small company on TikTok

It's tempting to think that, if you want people to know about your small business, you shouldn't be looking past the mainstream likes of Facebook, Instagram and Twitter for your social media marketing. However, sometimes, making a marketing breakthrough calls for a quirkier approach. This is...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

Facebook Adds a New Feature to its Creator Studio to Help Publishers with Managing Messages!

Facebook’s Creator Studio has just added a familiar feature. In case you are not aware, Creator Studio gives Publishers a platform to manage everything related to their Facebook pages and Instagram profiles, from one place. Posts, Messages and various Analytical factors can be accessed and...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Ali Siddiqui via Digital Information World

Microsoft introduces beta of its new, Chrome-based Edge browser

#405 — August 21, 2019

Read on the Web

Frontend Focus

Microsoft Introduces 'Ready for Everyday Use' Beta of Its Chrome-Based Edge Browser — Available for Windows and macOS, the beta release of Edge is the third and final preview release of Microsoft’s new Chromium-based browser, although Microsoft is declaring it ‘ready for everyday use’ with this release. It also includes the ‘Internet Explorer mode’ for back compatibility with IE 11. Time to get testing.

Joe Belfiore (Microsoft)

▶  Is CSS a 'Programming Language'? — An hour long conversation asking questions about the label CSS carries, and picking apart if being designated a ‘programming language’ would encourage uptake, or if such characterization may end up being an exercise in exclusion — and ultimately whether it even matters.

Heydon Pickering and Stephen Hay podcast

GraphQL Tutorials for Frontend Developers — Learn GraphQL by doing in just 2 hours with these open-source tutorials for React, ReactNative, Vue, Angular, Elm, Android, iOS, Flutter & ReasonML developers.

Hasura sponsor

Optional HTML: Everything You Need to Know — A good look at optional code (such as the quotation marks of an attribute value), and how the balance between understandability and performance don’t need to be at odds with each other.

Jens Oliver Meiert

iframes Are Just Terrible. Here’s How They Could Be Better. — Daniel Brian, a lead engineer at PayPal highlights some of the issues with using <iframe>. “I really hope browser vendors start to treat UI based iframes as more of a first-class citizen on the web, and help fix some of the above issues which are not poly-fillable right now.”

Daniel Brain

Google to Deprecate FTP Support in Chrome — By version 82, shipping in Q2 of 2020, all FTP support will be removed from Chrome. This is expected to affect around 0.1% of users though if you do still offer downloads in an FTP-only form, now is the time to upgrade.

Paul Hill

Custom Elements for The Immersive Web — An introduction to <img-360> and <video-360>, two new custom elements designed to work with 360° images and video.

Fernando Serrano

💻 Jobs

Senior Software Engineer - Frontend (100% Remote) — Do you have a solid understanding of web technologies and want to design, implement, and launch major user features? Apply now.

Close

Frontend Engineer - In Dili, Timor-Leste or Possibly Remote — Work with people globally to create change, using technology to empower people, through our programs in aid and global development.

Catalpa International

Frontend developers are in demand on Vettery — Make a free profile, name your salary, and connect with hiring managers from top employers.

Vettery

📙 Articles, Tutorials & Opinion

Efficiently Load Third-Party JavaScript — How to avoid the common pitfalls of using third-party scripts to improve load times and user experience.

Milica Mihajlija

Lazy Load Embedded YouTube Videos — Here’s a clever idea via Arthur Corenzan which avoids using the default YouTube embed — which adds a sizeable number of resources to a page.

CSS Tricks

Accessibility for Web Developers. Get the Whitepaper — Learn everything you need to know about accessibility standards, how to conform to the laws and what this means to you.

Progress Kendo UI sponsor

The (Upcoming) WordPress Renaissance — The author asserts that the introduction of Gutenberg has made for a “much richer” Wordpress user experience. Here, he takes a look at the CMSs latest developments, and where it is heading next.

Leonardo Losoviz

CSS Can Do This.. And It's Terrifying — A curious look at a few things you can do with CSS, but maybe shouldn’t (including key logging & user tracking).

Aaron Powell

Variable Font Animation with CSS and Splitting JS — A look at what variable fonts are, and how they can be animated with CSS and a little bit of JavaScript.

Michelle Barker

The evolt.org Browser Archive Is 20 Years Old — When this browser archive launched in 1999 it featured links to 80 different browsers.

Adrian Roselli

Keyboard Accessible Performance Timelines Now in Chromium

Microsoft Edge DevTools on Twitter

▶  Why You Don't Need BEM with Utility-First CSS

Adam Wathan

Roll Your Own Comment System for a Static Site

Tania Rascia

📱 Work in mobile dev? We publish a mobile-focused newsletter every Friday.

🔧 Code, Tools & Resources

pagemap: A 'Mini Map' for Web Pages — A neat little idea that’s particularly useful on long pages. This adds a clickable/navigable overview of an entire page to the top right corner. Here’s the associated repo.

Lars Jung

Lexend: A Variable Font Designed for Better Reading — This new font family, created with reading proficiency in mind, is now available in Google Fonts — you can read more about its creation here.

Thomas Jockin

Make Your Images & Videos Load Fast & Look Beautiful with Cloudinary

Cloudinary sponsor

Quicklink: Faster Subsequent Page-Loads by Prefetching Visible Links — We shared this project from Google Chrome Labs last year - but it has just seen an update. It aims to make subsequent page loads quicker by prefetching links that are currently in the viewport during idle time.

Google Chrome Labs

extra.css: A CSS Houdini Library — ..with plenty of fun effects.

Una Kravets

An Accessible, Simple, and CSS-Only Styled Checkbox

Jen Simmons codepen

   ðŸ—“ Upcoming Events

Web Unleashed 2019, September 13-14 — Toronto, Canada — Covers a variety of front-end topics leaving you 'informed, challenged and inspired'.

State of the Browser, September 14 — London, UK — A one-day, single-track conference with widely varying talks about the modern web.

CSSConf, September 25 — Budapest, Hungary — A community conference dedicated to the designers and developers who love CSS.

Accessibility Scotland, October 25 — Edinburgh, UK — One day of talks. Friendly, open discussion about accessibility.

🕰 ICYMI (Some older stuff that's worth checking out..)


by via Frontend Focus

Set up a Secure, Performant WooCommerce Site with Kinsta

Dragio.js : JavaScript Drag Drop File Upload Library

Dragio.js is a javascript class to work with file upload. Custom responsive forms, progress bars, drag ‘n’ drop function, Ctrl + V paste, image preview etc.

The post Dragio.js : JavaScript Drag Drop File Upload Library appeared first on Best jQuery.


by Admin via Best jQuery

Image.preview.js : jQuery Hoverable Image & Video Previews Plugin

A simple jQuery plugin that adds hoverable image and video previews to links and other elements.

The post Image.preview.js : jQuery Hoverable Image & Video Previews Plugin appeared first on Best jQuery.


by Admin via Best jQuery