Why you should try React Native
for your next mobile project.
Gwen Faraday
- Developer at Fusion Alliance
- freeCodeCamp Indy
- github.com/gwenf
- @gwen_faraday
- gwenfaraday@gmail.com
What is React Native?
- Mobile Apps in JavaScript
- Cross-platform
- Declarative
- Uses the React Paradigm
- Learn once build anywhere.
React - JSX
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
class App extends Component {
render() {
return (
Hello App!
); } } ReactDOM.render(
React - JSX
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
class App extends Component {
constructor () {
super();
this.state = {
count: 0
};
this.add = this.add.bind(this);
}
add () {
this.setState({
count: this.state.count + 1
});
}
render () {
return (
Count = {this.state.count}
);
}
}
ReactDOM.render( , document.getElementById('root'));
React Native - JSX
import React, { Component } from 'react';
import { AppRegistry, View, Text } from 'react-native';
class App extends Component {
render() {
return (
Hello App!
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => App);
React Native - JSX
import React, { Component } from 'react';
import {
AppRegistry,
View,
Text,
TouchableOpacity
} from 'react-native';
class App extends Component {
constructor () {
super();
this.state = {
count: 0
};
this.add = this.add.bind(this);
}
add () {
this.setState({
count: this.state.count + 1
});
}
render() {
return (
Count: {this.state.count}
Add One
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => App);
Default Styling with Flexbox
display: 'flex'
flex-direction: 'column'
Benefits of React Native
- Fast Developer Iteration
- Cross-platform code sharing
- Native Views
- Performance
- Built in developers tools
- Re-use web skills
Web Ecosystem
- Geolocation
- Fetch
- WebGL
- NPM/JS Libraries
iOS and Android

Why not use native?
- Cost
- Time
- Fewer Native Developers
- Maintenance
Other Solutions - Hybrid
- Faster Development Time
- Re-use web skills/developers
- Doesn't feel native!
Getting Started #1 - Easy
- Download the Expo mobile app on a phone
- Open snack.expo.io in a desktop browser
- Scan the qr code (with the Expo app)
- Start coding!
Getting Started #2
*Alternative to #1*
$ npm i -g create-react-native-app
$ create-react-native-app my-app
$ cd my-app
$ npm start
Getting Started #3 - Harder
- Install Node and Python
- Install React Native CLI
- Xcode and Android Studio
- Set up emulators and Marshmallow
- Configure environment variables
Project Setup
$ react-native init appName
$ react-native run-ios
$ react-native run-android
React Native

Styling Components

Which platform am I using?
const instructions = Platform.select({
ios: 'You are using iOS',
android: 'You are using Android'
});
if (Platform.os === 'ios') {
// do something
} else if (Platform.os === 'android') {
// do something
}
Datetime Picker

React Developer Tools
npm install --save-dev react-devtools
// add “devtools”: “react-devtools” to npm scripts
npm run devtools
React Developer Tools

Debugging
console.log(...);
console.warn(...);
console.error(...);
debugger;
Embedding Native Code
import React, { Component } from 'react';
import { NativeModules } from 'react-native';
Embed other people's native code - React Native Link
npm install react-native-camera
react-native link
Transitioning from a mobile friendly web app?
Embed Web Views!
import React, { Component } from 'react';
import { WebView } from 'react-native';
class MyWeb extends Component {
render() {
return (
);
}
}
Who is using React Native?
- Airbnb
- Wix
- Walmart
- Bloomberg
- Skype
- Tesla
- Discord
Some Bummers
- Restart the packager when installing native code libraries.
- Can only run one simulator at a time.
Workflow Example
- Planning/Mockups
- Ask myself: Do I need a design framework?
- Create Reuseable Components using Snacks
- Plan the folder/component structure
- Set up .eslintrc extending from AirBnb
- Set up redux for state management.
- Start building!
Resource Links
- Cross Platform UI Toolkit
- Browser-based development - Expo Sketch
- Flexbox Games - Froggies and Tower Defense
- React Native styling practice with Katas!
Up-to-date Information
Gwen Faraday
- Developer at Fusion Alliance
- freeCodeCamp Indy
- github.com/gwenf
- @gwen_faraday
- gwenfaraday@gmail.com
Thanks for Coming!
NDC London - React Native
By gwenf
NDC London - React Native
- 584