Book Image

React Native By Example

By : Richard Kho
Book Image

React Native By Example

By: Richard Kho

Overview of this book

React Native's ability to build performant mobile applications with JavaScript has resulted in its popularity amongst developers. Developers now have the luxury to create incredible mobile experiences that look and feel native to their platforms with the comfort of a well-known language and the popular React.js library. This book will show you how to build your own native mobile applications for the iOS and Android platforms while leveraging the finesse and simplicity of JavaScript and React. Throughout the book you will build three projects, each of increasing complexity. You will also link up with the third-party Facebook SDK, convert an app to support the Redux architecture, and learn the process involved in making your apps available for sale on the iOS App Store and Google Play. At the end of this book, you will have learned and implemented a wide breadth of core APIs and components found in the React Native framework that are necessary in creating great mobile experiences.
Table of Contents (17 chapters)
Title Page
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Writing in ES6


ECMAScript version 6 (ES6) is the latest specification of the JavaScript language. It is also referred to as ES2016. It brings new features and syntax to JavaScript, and they are the ones you should be familiar with to be successful in this book.

Firstly, require statements are now import statements. They are used to import functions, object, and so on from an external module or script. In the past, to include React in a file, we would write something like this:

var React = require('react'); 
var Component = React.Component; 

Using ES6 import statements, we can rewrite it to this:

import React, { Component } from 'react'; 

The importing of Component around a curly brace is called destructuring assignment. It's an assignment syntax that lets us extract specific data from an array or object into a variable. With Component imported through destructuring assignment, we can simply call Component in our code; it's automatically declared as a variable with the exact same name.

Next up, we're replacing var with two different statements: let and const. The first statement, let, declares a block-scoped variable whose value can be mutated. The second statement, const, declares another block-scoped variable whose value cannot change through reassignment nor redeclaration.

In the prior syntax, exporting modules used to be done using module.exports. In ES6, this is done using the export default statement.