react native for multi-platform mobile applications - matteo manchi - codemotion rome 2017

46
@matteomanchi Matteo Manchi ROME 24-25 MARCH 2017 React Native for multi-platform mobile applications

Upload: codemotion

Post on 05-Apr-2017

21 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Matteo Manchi

ROME 24-25 MARCH 2017

React Native for multi-platform mobile applications

Page 2: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Mobile Development

Page 3: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

… but necessary.

Mobile Development

Native is hard…

Page 4: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Different platforms

Page 5: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Different languages

Page 6: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Different look

Page 7: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

But what if we can use technologies we know?

Mobile Development

Page 8: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

■ Web developer friendly■ Native UI (vs WebView)■ Live Reload (vs Compile&Wait)■ Declarative UI (vs Imperative UI)■ Multi-platform support (vs specific support)■ Open Source

Why React Native?

Page 9: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Matteo ManchiFull stack developerReact enthusiastCo-founder of RomaJSCEO at ImprontaAdvance@matteomanchihttps://github.com/takeno

About Me

Page 10: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Web Developer

My journey to app development

⬇Mobile site version

⬇Mobile application ➡➡ WTF?

Page 11: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Phone Gap with box-shadow

Page 12: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Web Developer

My journey to app development

⬇Mobile site version

⬇Mobile application ➡

⬅⬅

Page 13: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Titanium - Red Screen of Death

Page 14: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Front-end experience

Page 15: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Codemotion 2015

https://facebook.github.io/react/blog/2015/03/26/introducing-react-native.html

Page 16: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Let's start from the beginning...

Page 17: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

React is a JavaScript library for building user interfaces.

■ Just the UI■ One-way data flow■ Virtual DOM■ From Facebook

What is React?

Page 18: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

■ Component: Everything is a component■ Props: some data passed to child component■ State: some internal data of a component■ JSX: XML-like syntax helps to define component's

structure■ Virtual DOM: tree of custom objects representing a port

of the DOM

Some keywords

Page 19: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Component definition

Page 20: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

A framework for building native apps using React.

React Native

Yeah, the same React of web developers

Learn once, write anywhere.

Page 21: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

■ brew install node■ brew install watchman■ npm install -g react-native-cli■ Install X-Code and/or Android SDK

■ react-native init SampleApp■ cd SampleApp■ react-native run-ios■ react-native run-android

Getting started

Page 22: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Component definition

Page 23: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Style

■ CSS-like declarations with camel-case properties■ style props defined for all native components

■ It can be an array of styles■ StyleSheet module to create multiple classes in one place

and cache them

It supports Flexbox!

Page 24: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Demo time!

Page 25: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

How it works

Native Bridge

Your code

JavaScript Core

bundle.js

Native View

render

Page 26: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

How it works

http://moduscreate.com/leverage-existing-ios-views-react-native-app/

Page 27: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

About multi-platform

Business logic in JavaScriptmeans same codebase

between platforms.

Page 28: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Platform-specific code

■ if/else method

■ Platform-specific extensions

Page 29: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

React Native wraps native UI components

Out-of-the-box

■ TabBar■ Text■ TextInput ■ Touchable ■ TouchableOpacity ■ Touchable Highlight ■ Touchable WithoutFeedback ■ View WebView

■ Activity Indicator■ Date Picker■ Image■ ListView■ MapView■ Navigator■ Picker■ ScrollView■ Slider

Page 30: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Out-of-the-box

■ InteractionManager■ Keyboard■ LayoutAnimation■ Linking■ NetInfo■ PanResponder■ PixelRatio■ Settings■ Share■ StatusBarIOS■ TimePickerAndroid■ ToastAndroid■ Vibration

■ ActionSheetIOS■ Alert■ Animated■ AppState■ AsyncStorage■ BackAndroid■ CameraRoll■ Clipboard■ DatePickerAndroid■ Dimensions■ Easing■ Geolocation■ ImageEditor

React Native wraps native API

Page 31: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Out-of-the-box

■ GeoLocation■ Timers

● setTimeout● setInterval

■ Flexbox■ Network

● XMLHttpRequest● Fetch

React Native injects polyfills in JS Core

Page 32: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Try it now!■ git clone

https://github.com/facebook/react-native.git

■ cd react-native■ npm install■ cd Examples/UIExplorer/■ open UIExplorer.xcodeproj■ Run

UIExplorer

Page 33: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Demo time!

Page 34: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

JSCore allows you to use your favoriteJavaScript modules and tools!

JS Ecosystem

Page 35: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

JS Debugging

Page 36: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

React Native’s community is very active■ 46k+ stars on Github■ 6500+ issue solved■ React Native Community on Github

React Native Ecosystem

Page 37: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

React Native Ecosystem

■ UI Components● native-base● react-native-elements● react-native-material-kit● react-native-material-design

■ Navigation● react-native-router-flux● react-navigation● native-navigation by AirBnB● wix/react-native-navigation

Hundreds of packages published:

■ Native API● react-native-maps by AirBnB● react-native-camera● react-native-onesignal● code-push by Microsoft

Page 38: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Specific tools to help your development

■ Deco IDEhttps://www.decosoftware.com

■ Sketch by expo.iocodepen-like playground for React Nativehttps://sketch.expo.io

■ FastlaneContinuous deployment for mobile appshttps://sketch.expo.io/

■ Create React Native AppStarter pack inspired by create-react-apphttps://github.com/react-community/create-react-native-app

React Native Ecosystem

Page 39: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

■ Hackatons■ MVP■ Web Developer teams■ Simple apps

Where is React Native now?

Page 40: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Facebook Ads Manager

Where is React Native now?

85% shared code between platforms

https://code.facebook.com/.../react-native-how-we-built-the-first-cross-platform

Page 41: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Where is React Native now?

Facebook AppFB event section is in RN

http://goo.gl/ziBzOl

Page 42: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

What’s next?

http://githubstats.com/facebook/react-native

Stars Forks

Pull Requests Issues

React Native’s community is very active

Page 43: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

“We use theexact same version

internally”

Tadeu ZagalloSoftware Engineer at Facebook

What’s next?

http://goo.gl/ziBzOl

Page 44: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

Woah! Woah!

Questions?

Page 45: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

ROME 24-25 MARCH 2017

THANK YOU!@matteomanchi

Page 46: React Native for multi-platform mobile applications  - Matteo Manchi - Codemotion Rome 2017

@matteomanchi

We’re looking for

JS enthusiastwho wants to

have funwith this cool technologies.

Contact me @matteomanchi

We’re hiring!

goo.gl/us55X3

More open positions: PHP Dev, Front-End Designer