Building cross-platform mobile apps with React Native (Jfokus 2017)

1
BUILDING APPS WITH
REACT NATIVE
@mthmuldersmaartenm@infosupport.com
 
2 . 1
2 . 2
. W . . .
S W O R N
S W O R D
S W E D E
3
DEMO TIME!
Getting started
4
BUT THERE'S...
... Cordova/PhoneGap
HTML, JavaScript, CSS
web-app inside browser inside app
 
... Xamarin
C#
includes Mono runtime
5 . 1
INTERNALS
Startup
Execution
Runtime
5 . 2
APPLICATION STARTUP
Application
Native Modules JavaScript VM JavaScript bundle
JSON configuration
Execute JavaScript
5 . 3
JAVASCRIPT EXECUTION
JavaScriptCore from WebKit (Safari)
Available on iOS, packaged on Android
Except when debugging in Chrome → V8
Parse Generate AST Generate Bytecode Run Bytecode
5 . 4
PROGRAM FLOW
Bridge
Native Module
JavaScript execution
Shadow Views Layout Native Views
Render (screen)
UI Kit
User
6 . 1
BUILDING YOUR APP
React
Styling
State / Redux
6 . 2
REACT
Declarative UI
Component-based
6 . 3
COMPONENTS
class HelloMessage extends React.Component {
render() {
return <div>Hello { this.props.name }</div>;
}
}
class App extends React.Component {
render() {
return <HelloMessage name={ 'Jfokus' } />;
}
}
ReactDOM.render(<App />, document.getElementById("app"));
6 . 4
ES6 & JSX
class HelloMessage extends React.Component {
render() {
return <div>Hello { this.props.name }</div>;
}
}
var HelloMessage = React.createClass({
render: function() {
return <div>Hello, { this.props.name }</div>;
}
});
var HelloMessage = React.createClass({
render: function() {
return React.createElement('div', null,
'Hello ' + this.props.name);
}
});
6 . 5
STYLING YOUR APP
No browser, no CSS, so...?
import { StyleSheet, Text } from "react-native";
const styles = StyleSheet.create({
red: {
color: "red" // or "#ff0000", or "rgb(255, 0, 0)"
}
});
class HelloMessage extends React.Component {
render() {
return <Text style={ styles.red }>...</Text>;
}
}
6 . 6
APPLICATION STATE
Item 1 Item 2 Item 3 Item ...
App
LoadingScreen
ListView
Should I pass my state down through all components?!
6 . 7
MEET REDUX!
Core ideas:
1. State is single source of truth
→ no copies
2. State is read-only
→ state is mutated by emitting actions
3. Changes are made with pure functions
→ reducers take current state and action (+ params)
→ always return new objects
BTW, pure functions are easy to test :)
6 . 8
DEMO
const initialState = { todos: [] };
const reducer = (state = initialState, action) => {
switch (action.type) {
case 'ADD_TODO':
const id = state.todos.length + 1;
const todo = { title: action.title, complete: false, id };
}
};
const store = createStore(reducer);
store.dispatch({ type: 'ADD_TODO', title: 'Speak at Jfokus' });
console.log(store.getState());
6 . 9
REACT-REDUX: REACT <3 REDUX
Provide Redux' store to your app
import { Provider } from 'react-redux';
const store = createStore(reducer);
<Provider store={ store }>
<LoadingScreen />
</Provider>
6 . 10
REACT-REDUX: REACT <3 REDUX
Connect components to Redux' store
import { Text } from 'react-native';
import { connect } from 'react-redux';
export const Counter = (props) => {
return (<Text>There are { props.count } tasks</Text>);
}
const mapStateToProps = (state) => {
return { count: state.todos.length };
}
const mapDispatchToProps = (dispatch) => {
return { };
}
export default connect(mapStateToProps, mapDispatchToProps)
(Counter);
7
DEMO TIME!
https://git.io/vMEuW
8
Q & A
1 of 21

Recommended

Pieter De Baets - An introduction to React Native by
Pieter De Baets - An introduction to React NativePieter De Baets - An introduction to React Native
Pieter De Baets - An introduction to React Nativetlv-ios-dev
3.3K views70 slides
Workshop 20: ReactJS Part II Flux Pattern & Redux by
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxVisual Engineering
1.2K views19 slides
Creating a WYSIWYG Editor with React by
Creating a WYSIWYG Editor with ReactCreating a WYSIWYG Editor with React
Creating a WYSIWYG Editor with Reactpeychevi
13.3K views65 slides
Workshop 22: React-Redux Middleware by
Workshop 22: React-Redux MiddlewareWorkshop 22: React-Redux Middleware
Workshop 22: React-Redux MiddlewareVisual Engineering
2.3K views29 slides
React Native Androidはなぜ動くのか by
React Native Androidはなぜ動くのかReact Native Androidはなぜ動くのか
React Native Androidはなぜ動くのかYukiya Nakagawa
11.2K views144 slides
Building Modern Apps using Android Architecture Components by
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
716 views64 slides

More Related Content

What's hot

React and redux by
React and reduxReact and redux
React and reduxMystic Coders, LLC
2.9K views39 slides
Workshop React.js by
Workshop React.jsWorkshop React.js
Workshop React.jsCommit University
2.2K views100 slides
Extending Kubernetes with Operators by
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operatorspeychevi
188 views47 slides
Internal workshop react-js-mruiz by
Internal workshop react-js-mruizInternal workshop react-js-mruiz
Internal workshop react-js-mruizMiguel Ruiz Rodriguez
326 views23 slides
Introduction to react_js by
Introduction to react_jsIntroduction to react_js
Introduction to react_jsMicroPyramid .
1.7K views16 slides
Introduction to React JS by
Introduction to React JSIntroduction to React JS
Introduction to React JSArno Lordkronos
32.5K views21 slides

What's hot(20)

Extending Kubernetes with Operators by peychevi
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operators
peychevi188 views
Fundamental concepts of react js by StephieJohn
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
StephieJohn98 views
Getting Started with React-Nathan Smith by TandemSeven
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan Smith
TandemSeven2.7K views
Get rid of controllers in angular 1.5.x start using component directives by Marios Fakiolas
Get rid of controllers in angular 1.5.x start using component directivesGet rid of controllers in angular 1.5.x start using component directives
Get rid of controllers in angular 1.5.x start using component directives
Marios Fakiolas2K views
Introduction to ReactJS by Hoang Long
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
Hoang Long5.3K views
Angular2 & ngrx/store: Game of States by Oren Farhi
Angular2 & ngrx/store: Game of StatesAngular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
Oren Farhi5.5K views
How Angular2 Can Improve Your AngularJS Apps Today! by Nir Kaufman
How Angular2 Can Improve Your AngularJS Apps Today!How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!
Nir Kaufman1.8K views
React js programming concept by Tariqul islam
React js programming conceptReact js programming concept
React js programming concept
Tariqul islam1.4K views
7 Redux challenges by reactima
7 Redux challenges7 Redux challenges
7 Redux challenges
reactima1.9K views
React native app with type script tutorial by Katy Slemon
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
Katy Slemon101 views
Test Driven Development with JavaFX by Hendrik Ebbers
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
Hendrik Ebbers16.5K views
React JS: A Secret Preview by valuebound
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
valuebound3.3K views
Angular 2: core concepts by Codemotion
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
Codemotion1.2K views

Viewers also liked

Interfaz caro by
Interfaz  caroInterfaz  caro
Interfaz caro0604937011
103 views6 slides
Вестник фокуса Февраль 2017 by
Вестник фокуса Февраль 2017Вестник фокуса Февраль 2017
Вестник фокуса Февраль 2017Гипермаркет Теорема
134 views16 slides
Force and Motion Vocabulary by
Force and Motion VocabularyForce and Motion Vocabulary
Force and Motion VocabularyMrsPadgett
433 views11 slides
JMC Academy - International Prospectus by
JMC Academy - International ProspectusJMC Academy - International Prospectus
JMC Academy - International ProspectusGood Education Group
649 views28 slides
Sublimation blanks suppliers in india by
Sublimation blanks suppliers in indiaSublimation blanks suppliers in india
Sublimation blanks suppliers in indiasublitech1
155 views15 slides
Madhukeshwar T Moldflow Bronze Certificate by
Madhukeshwar T   Moldflow Bronze CertificateMadhukeshwar T   Moldflow Bronze Certificate
Madhukeshwar T Moldflow Bronze CertificateMadhukeshwar T.Kampli
427 views1 slide

Viewers also liked(16)

Interfaz caro by 0604937011
Interfaz  caroInterfaz  caro
Interfaz caro
0604937011103 views
Force and Motion Vocabulary by MrsPadgett
Force and Motion VocabularyForce and Motion Vocabulary
Force and Motion Vocabulary
MrsPadgett433 views
Sublimation blanks suppliers in india by sublitech1
Sublimation blanks suppliers in indiaSublimation blanks suppliers in india
Sublimation blanks suppliers in india
sublitech1155 views
Mold flow from hi precision by Huang Simon
Mold flow from hi precisionMold flow from hi precision
Mold flow from hi precision
Huang Simon627 views
Hissies 2017 by Tim Histalk
Hissies 2017Hissies 2017
Hissies 2017
Tim Histalk24.9K views
Regiões agro ecológicas de moçambique pdf by Credencio Maunze
Regiões agro ecológicas de moçambique pdfRegiões agro ecológicas de moçambique pdf
Regiões agro ecológicas de moçambique pdf
Credencio Maunze37.2K views
Diapositivas planificacion y presupuesto diplomado ministerio publico enero 2012 by cefic
Diapositivas planificacion y presupuesto diplomado ministerio publico enero 2012Diapositivas planificacion y presupuesto diplomado ministerio publico enero 2012
Diapositivas planificacion y presupuesto diplomado ministerio publico enero 2012
cefic695 views

Similar to Building cross-platform mobile apps with React Native (Jfokus 2017)

React Native for multi-platform mobile applications by
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsMatteo Manchi
1.6K views39 slides
React native by example by Vadim Ruban by
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim RubanLohika_Odessa_TechTalks
899 views67 slides
SproutCore is Awesome - HTML5 Summer DevFest by
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFesttomdale
704 views39 slides
React 101 by Anatoliy Sieryi by
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi Binary Studio
295 views53 slides
React Native in Production by
React Native in ProductionReact Native in Production
React Native in ProductionSeokjun Kim
1.4K views49 slides
React Native by
React NativeReact Native
React NativeCraig Jolicoeur
1K views39 slides

Similar to Building cross-platform mobile apps with React Native (Jfokus 2017)(20)

React Native for multi-platform mobile applications by Matteo Manchi
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
Matteo Manchi1.6K views
SproutCore is Awesome - HTML5 Summer DevFest by tomdale
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
tomdale704 views
React 101 by Anatoliy Sieryi by Binary Studio
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi
Binary Studio295 views
React Native in Production by Seokjun Kim
React Native in ProductionReact Native in Production
React Native in Production
Seokjun Kim1.4K views
Introduction to React for Frontend Developers by Sergio Nakamura
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
Sergio Nakamura17 views
Developer Student Clubs NUK - Flutter for Beginners by Jiaxuan Lin
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
Jiaxuan Lin383 views
Workshop 26: React Native - The Native Side by Visual Engineering
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
Visual Engineering2.8K views
Fundamental Concepts of React JS for Beginners.pdf by StephieJohn
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdf
StephieJohn110 views
Meteor Meet-up San Diego December 2014 by Lou Sacco
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014
Lou Sacco730 views
React Native +Redux + ES6 (Updated) by Chiew Carol
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol694 views
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi by Yukiya Nakagawa
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
Yukiya Nakagawa25.1K views
Developing large scale JavaScript applications by Milan Korsos
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
Milan Korsos2K views
React JS and Redux by Glib Kechyn
React JS and ReduxReact JS and Redux
React JS and Redux
Glib Kechyn366 views

More from Maarten Mulders

What's cooking in Maven? (Devoxx FR) by
What's cooking in Maven? (Devoxx FR)What's cooking in Maven? (Devoxx FR)
What's cooking in Maven? (Devoxx FR)Maarten Mulders
173 views25 slides
Making Maven Marvellous (Devnexus) by
Making Maven Marvellous (Devnexus)Making Maven Marvellous (Devnexus)
Making Maven Marvellous (Devnexus)Maarten Mulders
149 views13 slides
Making Maven Marvellous (Java.il) by
Making Maven Marvellous (Java.il)Making Maven Marvellous (Java.il)
Making Maven Marvellous (Java.il)Maarten Mulders
146 views13 slides
Making Maven Marvellous (JavaZone) by
Making Maven Marvellous (JavaZone)Making Maven Marvellous (JavaZone)
Making Maven Marvellous (JavaZone)Maarten Mulders
90 views13 slides
Dapr: Dinosaur or Developer's Dream? (v1) by
Dapr: Dinosaur or Developer's Dream? (v1)Dapr: Dinosaur or Developer's Dream? (v1)
Dapr: Dinosaur or Developer's Dream? (v1)Maarten Mulders
132 views42 slides
Dapr: Dinosaur or Developer Dream? (J-Fall) by
Dapr: Dinosaur or Developer Dream? (J-Fall)Dapr: Dinosaur or Developer Dream? (J-Fall)
Dapr: Dinosaur or Developer Dream? (J-Fall)Maarten Mulders
137 views42 slides

More from Maarten Mulders(20)

What's cooking in Maven? (Devoxx FR) by Maarten Mulders
What's cooking in Maven? (Devoxx FR)What's cooking in Maven? (Devoxx FR)
What's cooking in Maven? (Devoxx FR)
Maarten Mulders173 views
Making Maven Marvellous (Devnexus) by Maarten Mulders
Making Maven Marvellous (Devnexus)Making Maven Marvellous (Devnexus)
Making Maven Marvellous (Devnexus)
Maarten Mulders149 views
Making Maven Marvellous (Java.il) by Maarten Mulders
Making Maven Marvellous (Java.il)Making Maven Marvellous (Java.il)
Making Maven Marvellous (Java.il)
Maarten Mulders146 views
Dapr: Dinosaur or Developer's Dream? (v1) by Maarten Mulders
Dapr: Dinosaur or Developer's Dream? (v1)Dapr: Dinosaur or Developer's Dream? (v1)
Dapr: Dinosaur or Developer's Dream? (v1)
Maarten Mulders132 views
Dapr: Dinosaur or Developer Dream? (J-Fall) by Maarten Mulders
Dapr: Dinosaur or Developer Dream? (J-Fall)Dapr: Dinosaur or Developer Dream? (J-Fall)
Dapr: Dinosaur or Developer Dream? (J-Fall)
Maarten Mulders137 views
React in 40 minutes (Voxxed Days Romania) by Maarten Mulders
React in 40 minutes (Voxxed Days Romania) React in 40 minutes (Voxxed Days Romania)
React in 40 minutes (Voxxed Days Romania)
Maarten Mulders93 views
React in 50 minutes (Bucharest Software Craftsmanship Community) by Maarten Mulders
React in 50 minutes (Bucharest Software Craftsmanship Community)React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)
Maarten Mulders244 views
React in 50 Minutes (JNation) by Maarten Mulders
 React in 50 Minutes (JNation)  React in 50 Minutes (JNation)
React in 50 Minutes (JNation)
Maarten Mulders143 views
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour) by Maarten Mulders
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
Maarten Mulders127 views
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour) by Maarten Mulders
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
Maarten Mulders114 views
SSL/TLS for Mortals (UtrechtJUG) by Maarten Mulders
SSL/TLS for Mortals (UtrechtJUG)SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)
Maarten Mulders202 views
Building a DSL with GraalVM (javaBin online) by Maarten Mulders
Building a DSL with GraalVM (javaBin online)Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)
Maarten Mulders221 views
SSL/TLS for Mortals (Lockdown Lecture) by Maarten Mulders
SSL/TLS for Mortals (Lockdown Lecture)SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)
Maarten Mulders122 views
React in 50 Minutes (OpenValue) by Maarten Mulders
React in 50 Minutes (OpenValue) React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue)
Maarten Mulders162 views
React in 50 Minutes (DevNexus) by Maarten Mulders
React in 50 Minutes (DevNexus) React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus)
Maarten Mulders114 views

Recently uploaded

LAVADORA ROLO.docx by
LAVADORA ROLO.docxLAVADORA ROLO.docx
LAVADORA ROLO.docxSamuelRamirez83524
7 views1 slide
HarshithAkkapelli_Presentation.pdf by
HarshithAkkapelli_Presentation.pdfHarshithAkkapelli_Presentation.pdf
HarshithAkkapelli_Presentation.pdfharshithakkapelli
11 views16 slides
Roadmap y Novedades de producto by
Roadmap y Novedades de productoRoadmap y Novedades de producto
Roadmap y Novedades de productoNeo4j
43 views33 slides
DevsRank by
DevsRankDevsRank
DevsRankdevsrank786
10 views1 slide
How to Install and Activate Email-Researcher by
How to Install and Activate Email-ResearcherHow to Install and Activate Email-Researcher
How to Install and Activate Email-ResearchereGrabber
19 views8 slides
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Donato Onofri
643 views34 slides

Recently uploaded(20)

Roadmap y Novedades de producto by Neo4j
Roadmap y Novedades de productoRoadmap y Novedades de producto
Roadmap y Novedades de producto
Neo4j43 views
How to Install and Activate Email-Researcher by eGrabber
How to Install and Activate Email-ResearcherHow to Install and Activate Email-Researcher
How to Install and Activate Email-Researcher
eGrabber19 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri643 views
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan... by Deltares
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...
DSD-INT 2023 Baseline studies for Strategic Coastal protection for Long Islan...
Deltares10 views
El Arte de lo Possible by Neo4j
El Arte de lo PossibleEl Arte de lo Possible
El Arte de lo Possible
Neo4j34 views
Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ... by marksimpsongw
Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ...Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ...
Mark Simpson - UKOUG23 - Refactoring Monolithic Oracle Database Applications ...
marksimpsongw74 views
Tridens DevOps by Tridens
Tridens DevOpsTridens DevOps
Tridens DevOps
Tridens9 views
DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)... by Deltares
DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)...DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)...
DSD-INT 2023 Modelling litter in the Yarra and Maribyrnong Rivers (Australia)...
Deltares9 views
What Can Employee Monitoring Software Do?​ by wAnywhere
What Can Employee Monitoring Software Do?​What Can Employee Monitoring Software Do?​
What Can Employee Monitoring Software Do?​
wAnywhere18 views
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida by Deltares
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - PridaDSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
DSD-INT 2023 Dam break simulation in Derna (Libya) using HydroMT_SFINCS - Prida
Deltares17 views
Les nouveautés produit Neo4j by Neo4j
 Les nouveautés produit Neo4j Les nouveautés produit Neo4j
Les nouveautés produit Neo4j
Neo4j27 views
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko... by Deltares
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
DSD-INT 2023 Simulation of Coastal Hydrodynamics and Water Quality in Hong Ko...
Deltares10 views
Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea... by Safe Software
Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea...Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea...
Geospatial Synergy: Amplifying Efficiency with FME & Esri ft. Peak Guest Spea...
Safe Software391 views

Building cross-platform mobile apps with React Native (Jfokus 2017)

  • 1. 1 BUILDING APPS WITH REACT NATIVE @mthmuldersmaartenm@infosupport.com
  • 2.  
  • 3. 2 . 1 2 . 2 . W . . . S W O R N S W O R D S W E D E
  • 5. 4 BUT THERE'S... ... Cordova/PhoneGap HTML, JavaScript, CSS web-app inside browser inside app   ... Xamarin C# includes Mono runtime
  • 7. 5 . 2 APPLICATION STARTUP Application Native Modules JavaScript VM JavaScript bundle JSON configuration Execute JavaScript
  • 8. 5 . 3 JAVASCRIPT EXECUTION JavaScriptCore from WebKit (Safari) Available on iOS, packaged on Android Except when debugging in Chrome → V8 Parse Generate AST Generate Bytecode Run Bytecode
  • 9. 5 . 4 PROGRAM FLOW Bridge Native Module JavaScript execution Shadow Views Layout Native Views Render (screen) UI Kit User
  • 10. 6 . 1 BUILDING YOUR APP React Styling State / Redux
  • 11. 6 . 2 REACT Declarative UI Component-based
  • 12. 6 . 3 COMPONENTS class HelloMessage extends React.Component { render() { return <div>Hello { this.props.name }</div>; } } class App extends React.Component { render() { return <HelloMessage name={ 'Jfokus' } />; } } ReactDOM.render(<App />, document.getElementById("app"));
  • 13. 6 . 4 ES6 & JSX class HelloMessage extends React.Component { render() { return <div>Hello { this.props.name }</div>; } } var HelloMessage = React.createClass({ render: function() { return <div>Hello, { this.props.name }</div>; } }); var HelloMessage = React.createClass({ render: function() { return React.createElement('div', null, 'Hello ' + this.props.name); } });
  • 14. 6 . 5 STYLING YOUR APP No browser, no CSS, so...? import { StyleSheet, Text } from "react-native"; const styles = StyleSheet.create({ red: { color: "red" // or "#ff0000", or "rgb(255, 0, 0)" } }); class HelloMessage extends React.Component { render() { return <Text style={ styles.red }>...</Text>; } }
  • 15. 6 . 6 APPLICATION STATE Item 1 Item 2 Item 3 Item ... App LoadingScreen ListView Should I pass my state down through all components?!
  • 16. 6 . 7 MEET REDUX! Core ideas: 1. State is single source of truth → no copies 2. State is read-only → state is mutated by emitting actions 3. Changes are made with pure functions → reducers take current state and action (+ params) → always return new objects BTW, pure functions are easy to test :)
  • 17. 6 . 8 DEMO const initialState = { todos: [] }; const reducer = (state = initialState, action) => { switch (action.type) { case 'ADD_TODO': const id = state.todos.length + 1; const todo = { title: action.title, complete: false, id }; } }; const store = createStore(reducer); store.dispatch({ type: 'ADD_TODO', title: 'Speak at Jfokus' }); console.log(store.getState());
  • 18. 6 . 9 REACT-REDUX: REACT <3 REDUX Provide Redux' store to your app import { Provider } from 'react-redux'; const store = createStore(reducer); <Provider store={ store }> <LoadingScreen /> </Provider>
  • 19. 6 . 10 REACT-REDUX: REACT <3 REDUX Connect components to Redux' store import { Text } from 'react-native'; import { connect } from 'react-redux'; export const Counter = (props) => { return (<Text>There are { props.count } tasks</Text>); } const mapStateToProps = (state) => { return { count: state.todos.length }; } const mapDispatchToProps = (dispatch) => { return { }; } export default connect(mapStateToProps, mapDispatchToProps) (Counter);