SlideShare a Scribd company logo
1 of 21
Download to read offline
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

More Related Content

What's hot

What's hot (20)

React and redux
React and reduxReact and redux
React and redux
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
Extending Kubernetes with Operators
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operators
 
Internal workshop react-js-mruiz
Internal workshop react-js-mruizInternal workshop react-js-mruiz
Internal workshop react-js-mruiz
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Getting Started with React-Nathan Smith
Getting Started with React-Nathan SmithGetting Started with React-Nathan Smith
Getting Started with React-Nathan Smith
 
Get rid of controllers in angular 1.5.x start using component directives
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
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Angular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of StatesAngular2 & ngrx/store: Game of States
Angular2 & ngrx/store: Game of States
 
How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!How Angular2 Can Improve Your AngularJS Apps Today!
How Angular2 Can Improve Your AngularJS Apps Today!
 
Intro react js
Intro react jsIntro react js
Intro react js
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
7 Redux challenges
7 Redux challenges7 Redux challenges
7 Redux challenges
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
Angular 2: core concepts
Angular 2: core conceptsAngular 2: core concepts
Angular 2: core concepts
 

Viewers also liked

Regiões agro ecológicas de moçambique pdf
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 Maunze
 
Diapositivas planificacion y presupuesto diplomado ministerio publico enero 2012
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
cefic
 

Viewers also liked (16)

Interfaz caro
Interfaz  caroInterfaz  caro
Interfaz caro
 
Вестник фокуса Февраль 2017
Вестник фокуса Февраль 2017Вестник фокуса Февраль 2017
Вестник фокуса Февраль 2017
 
Force and Motion Vocabulary
Force and Motion VocabularyForce and Motion Vocabulary
Force and Motion Vocabulary
 
JMC Academy - International Prospectus
JMC Academy - International ProspectusJMC Academy - International Prospectus
JMC Academy - International Prospectus
 
Sublimation blanks suppliers in india
Sublimation blanks suppliers in indiaSublimation blanks suppliers in india
Sublimation blanks suppliers in india
 
Madhukeshwar T Moldflow Bronze Certificate
Madhukeshwar T   Moldflow Bronze CertificateMadhukeshwar T   Moldflow Bronze Certificate
Madhukeshwar T Moldflow Bronze Certificate
 
Mold flow from hi precision
Mold flow from hi precisionMold flow from hi precision
Mold flow from hi precision
 
8º ano reda cem - 8.2
8º ano   reda cem - 8.2 8º ano   reda cem - 8.2
8º ano reda cem - 8.2
 
Lista 6.2
Lista 6.2Lista 6.2
Lista 6.2
 
984
984984
984
 
Concussion in sport aug 2015
Concussion in sport aug 2015Concussion in sport aug 2015
Concussion in sport aug 2015
 
Hissies 2017
Hissies 2017Hissies 2017
Hissies 2017
 
[Connect 系列活動] 歐洲矽谷─愛爾蘭蛻變大解密
[Connect 系列活動] 歐洲矽谷─愛爾蘭蛻變大解密[Connect 系列活動] 歐洲矽谷─愛爾蘭蛻變大解密
[Connect 系列活動] 歐洲矽谷─愛爾蘭蛻變大解密
 
Regiões agro ecológicas de moçambique pdf
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
 
Pedologia
PedologiaPedologia
Pedologia
 
Diapositivas planificacion y presupuesto diplomado ministerio publico enero 2012
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
 

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

React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
Yukiya Nakagawa
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 

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

React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
 
React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi
 
React Native in Production
React Native in ProductionReact Native in Production
React Native in Production
 
React Native
React NativeReact Native
React Native
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdf
 
Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014Meteor Meet-up San Diego December 2014
Meteor Meet-up San Diego December 2014
 
Simple React Todo List
Simple React Todo ListSimple React Todo List
Simple React Todo List
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Developing large scale JavaScript applications
Developing large scale JavaScript applicationsDeveloping large scale JavaScript applications
Developing large scale JavaScript applications
 
Compose In Practice
Compose In PracticeCompose In Practice
Compose In Practice
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 

More from Maarten Mulders

More from Maarten Mulders (20)

What's cooking in Maven? (Devoxx FR)
What's cooking in Maven? (Devoxx FR)What's cooking in Maven? (Devoxx FR)
What's cooking in Maven? (Devoxx FR)
 
Making Maven Marvellous (Devnexus)
Making Maven Marvellous (Devnexus)Making Maven Marvellous (Devnexus)
Making Maven Marvellous (Devnexus)
 
Making Maven Marvellous (Java.il)
Making Maven Marvellous (Java.il)Making Maven Marvellous (Java.il)
Making Maven Marvellous (Java.il)
 
Making Maven Marvellous (JavaZone)
Making Maven Marvellous (JavaZone)Making Maven Marvellous (JavaZone)
Making Maven Marvellous (JavaZone)
 
Dapr: Dinosaur or Developer's Dream? (v1)
Dapr: Dinosaur or Developer's Dream? (v1)Dapr: Dinosaur or Developer's Dream? (v1)
Dapr: Dinosaur or Developer's Dream? (v1)
 
Dapr: Dinosaur or Developer Dream? (J-Fall)
Dapr: Dinosaur or Developer Dream? (J-Fall)Dapr: Dinosaur or Developer Dream? (J-Fall)
Dapr: Dinosaur or Developer Dream? (J-Fall)
 
SSL/TLS for Mortals (Devoxx UK)
SSL/TLS for Mortals (Devoxx UK)SSL/TLS for Mortals (Devoxx UK)
SSL/TLS for Mortals (Devoxx UK)
 
React in 40 minutes (Voxxed Days Romania)
React in 40 minutes (Voxxed Days Romania) React in 40 minutes (Voxxed Days Romania)
React in 40 minutes (Voxxed Days Romania)
 
React in 40 minutes (JCON)
React in 40 minutes (JCON) React in 40 minutes (JCON)
React in 40 minutes (JCON)
 
React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)React in 50 minutes (Bucharest Software Craftsmanship Community)
React in 50 minutes (Bucharest Software Craftsmanship Community)
 
React in 50 Minutes (JNation)
 React in 50 Minutes (JNation)  React in 50 Minutes (JNation)
React in 50 Minutes (JNation)
 
SSL/TLS for Mortals (JavaLand)
SSL/TLS for Mortals (JavaLand) SSL/TLS for Mortals (JavaLand)
SSL/TLS for Mortals (JavaLand)
 
Making Maven Marvellous (J-Fall)
Making Maven Marvellous (J-Fall)Making Maven Marvellous (J-Fall)
Making Maven Marvellous (J-Fall)
 
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)
Building a DSL with GraalVM (Oracle Groundbreaker APAC Virtual Tour)
 
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)
SSL/TLS for Mortals (Oracle Groundbreaker EMEA Virtual Tour)
 
SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)SSL/TLS for Mortals (UtrechtJUG)
SSL/TLS for Mortals (UtrechtJUG)
 
Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)Building a DSL with GraalVM (javaBin online)
Building a DSL with GraalVM (javaBin online)
 
SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)SSL/TLS for Mortals (Lockdown Lecture)
SSL/TLS for Mortals (Lockdown Lecture)
 
React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue) React in 50 Minutes (OpenValue)
React in 50 Minutes (OpenValue)
 
React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus) React in 50 Minutes (DevNexus)
React in 50 Minutes (DevNexus)
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

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);