SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
1
20 1 8 ISIT
1
­
­
­
­
­ Expo Snack
­ UI React React
­
­
­ React
­ Expo SDK
2
REACT
3
REACT
4
UI
JavaScript
DOM
React
Node
React Native
DECLARATIVE
­
­
5
(+ 1 2 3 4 5) ;15
var sum = function(arr){
var sum=0;
for(var i=0; i < arr.length; i++){
sum += arr[i];
}
return sum;
}
var arr = [1, 2, 3, 4, 5];
console.log( sum(arr) ); // 15
sum [1,2,3,4,5] --15
6
function double (arr) {
let results = []
for (let i = 0; i < arr.length; i++){
results.push(arr[i] * 2)
}
return results
}
function double (arr) {
return arr.map((item) => item * 2)
}
function add (arr) {
let result = 0
for (let i = 0; i < arr.length; i++){
result += arr[i]
}
return result
}
function add (arr) {
return arr.reduce((prev, current) => prev + current, 0)
}
$("#btn").click(function() {
$(this).toggleClass("highlight")
$(this).text() === 'Add Highlight'
? $(this).text('Remove Highlight')
: $(this).text('Add Highlight')
})
<Btn
onToggleHighlight={this.handleToggleHighlight}
highlight={this.state.highlight}>
{this.state.buttonText}
</Btn>
https://tylermcginnis.com/imperative-vs-declarative-programming/
CBD: Component-based development
­ separation
of concerns
­
7
https://en.wikipedia.org/wiki/Component-based_software_engineering
https://medium.com/@dan.shapiro1210/understanding-component-based-architecture-3ff48ec0c238
•
•
•
REACT
8
class Welcome extends React.Component {
state = {name: 'Anzu'};
render() {
return (
<div>
<h1>Hello, {this.props.name}</h1>
<div>My name is {this.state.name}</div>
</div>
);
}
}
class App extends React.Component {
render() {
return (
<div>
<Welcome name="Taro" />
<Welcome name="Hanako" />
</div>
);
}
}
View
9
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
Functional
•
•
•
Functional
REACT VER. 16.4
10http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/
LEARN ONCE, WRITE ANYWHERE
Java
­ Write once, run anywhere
­
­ React
­ iOS, android : React Native
­ Win, Mac React Desktop (https://reactdesktop.js.org/)
11https://reactjs.org/blog/2015/03/26/introducing-react-native.html
ES2015 ECMASCRIPT2015
12
let
let name = 'taro';
name = 'hanako'
const
const name = 'taro';
name = 'hanako'; // error
class
class Person { constructor(name){
this.name = name;
}
}
const person = new Person('taro')
const fn = (name) =>{
return console.log(name);
}
const arr = ['a', 'b', 'c'];
const arr2 = [...arr];
console.log(arr === arr2); // false
const name = 'taro';
console.log(`My name is ${name}.`); // My name is taro.
https://babeljs.io/docs/en/learn/
Expo ES6 6th Edition
extract(‘test.txt’, function(data1){
transform(data1, function(data2){
load(data2, function(data3){
console.log(‘done: ’, data3);
});
});
});
var promise = Promise.resolve();
promise
.then(()=> extract(‘text.txt’));
.then(data1=> transform(data1))
.then(data2=> load(data2))
.then((data3)=> console.log(‘done: , data3 ’))
async ()=>{
let data1 = await extract(‘test.txt’);
let data2 = await transform(data1);
let data3 = await load(data2);
console.log(‘done: ’, data3);
}
ES5
13
ES2015(ES6) Promise, ES2017(ES8) async/await
Expo ES8 async/await
JSX JAVASCRIPT XML, JAVASCRIPT SYNTAX EXTENSION
14
XML JavaScript
<MyButton color="blue" shadowSize={2}>
Click Me
</MyButton>
React.createElement(
MyButton,
{color: 'blue', shadowSize: 2},
'Click Me'
)
<div className="sidebar" />
React.createElement(
'div',
{className: 'sidebar'},
null
)
https://reactjs.org/docs/introducing-jsx.html
JSX React.createElement(component, props, ...children)
DOM
DOM ReactDOM
DOM
DOM
React DOM
15
DOM DOM
Key
{todos.map((todo, index) =>
<Todo
{...todo}
key={index}
/>
)}
{todos.map((todo) =>
<Todo {...todo}
key={todo.id} />
)}
ID
var shortid = require('shortid');
function createNewTodo(text) {
return {
completed: false,
id: shortid.generate(),
text
}
}
ID
todoCounter = 1;
function createNewTodo(text) {
return {
completed: false,
id: todoCounter++,
text
}
}
https://reactjs.org/docs/faq-internals.html
https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318
shortid
ID
EXPO SDK
16
EXPO SDK
­ Web
­
iOS, Android API
­ API API
17
Core Motion iOS Google Fit Android
Pedometer (Expo SDK)
API
18
AR Accelerometer Admob Amplitude AppLoading ART
Asset Audio AuthSession
Web
AV BarCodeScanner BlurView
Branch Brghtness Calendar Camera Constants
ID
Contacts
DeviceMotion DocumentPicker ErrorRecovery FacebookAds Facebook
Graph API
FaceDetector
FileSystem Font GestureHandler GLView
OpenGL ES
Google
Google
Gyroscope
Haptic ImageManipulator ImagePicker IntentLauncherAndroid KeepAwake LinerGradient
Linking LocalAuthentication Localization Location Lottie Magnetometer
MailComposer MapView MediaLibrary Notifications Payments Pedometer
Permissions Print registerRootComponent ScreenOrientation SecureStore Segment
SMS Speech SplashScreen SQLite StoreReview Svg
SVG
takeSnapshotAsync Updates Video WebBrowser
LOCATION
19
Expo.Location.getCurrentPositionAsync(options)
Expo.Location.watchPositionAsync(options, callback)
Expo.Location.getProviderStatusAsync()
Expo.Location.getHeadingAsync()
Expo.Location.watchHeadingAsync(callback)
Expo.Location.geocodeAsync(address)
Expo.Location.reverseGeocodeAsync(location)
Expo.Location.setApiKey(apiKey) Google API
https://snack.expo.io/@tygoto/location
LOCATION
20
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted’)
console.log('Permission to access location was denied');
Permissions API
let location = await Location.getCurrentPositionAsync({});
// address = await Location.reverseGeocodeAsync(loc)
// Location.watchHeadingAsync(this._getHeadingAsync)
//
//
PEDOMETER
Core Motion iOS Google Fit Android
21
Expo.Pedometer.isAvailableAsync()
Expo.Pedometer.getStepCountAsync(start, end)
Expo.Pedometer.watchStepCount(callback)
https://snack.expo.io/@tygoto/pedometer
PEDOMETER
22
componentDidMount() {
this._subscription = Pedometer.watchStepCount(result => {
this.setState({
currentStepCount: result.steps,
});
});
}
componentWillUnmount() {
this._subscription && this._subscription.remove();
this._subscription = null;
}
Pedometer.getStepCountAsync
CAMERA
23
https://snack.expo.io/@tygoto/camera
CAMERA
24
Camera.Constants.Type.back
front
ref={ref => {
this.cameraRef = ref;
}}>
let photo = await this.cameraRef.takePictureAsync();
OPEN DATA EXPO SDK
25
OPEN DATA EXPO SDK
http://data.bodik.jp/dataset
­
­ http://data.bodik.jp/dataset/atmospheric48
­
­ http://data.bodik.jp/dataset/401000_koutsuujiko2017
­
­
­
­
Expo SDK
26
1.
2.
3.
4.
27
React
­
­ ES2015, JSX, DOM
Expo SDK Expo SDK API
Open Data Expo SDK
­ Expo SDK
­
28

Weitere ähnliche Inhalte

Was ist angesagt?

Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
Sages
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
Alexander Mostovenko
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
Vaclav Pech
 

Was ist angesagt? (20)

The redux saga begins
The redux saga beginsThe redux saga begins
The redux saga begins
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 
All you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsAll you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, Generators
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
RxJS Evolved
RxJS EvolvedRxJS Evolved
RxJS Evolved
 
rx.js make async programming simpler
rx.js make async programming simplerrx.js make async programming simpler
rx.js make async programming simpler
 
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
Yurii Shevtsov "V8 + libuv = Node.js. Under the hood"
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.9 book - Part 71 of 210The Ring programming language version 1.9 book - Part 71 of 210
The Ring programming language version 1.9 book - Part 71 of 210
 
The evolution of redux action creators
The evolution of redux action creatorsThe evolution of redux action creators
The evolution of redux action creators
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180
 
Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223Jarmo van de Seijp Shadbox ERC223
Jarmo van de Seijp Shadbox ERC223
 
Add Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJSAdd Some Fun to Your Functional Programming With RXJS
Add Some Fun to Your Functional Programming With RXJS
 
Swift Sequences & Collections
Swift Sequences & CollectionsSwift Sequences & Collections
Swift Sequences & Collections
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189
 
Js interpreter interpreted
Js interpreter interpretedJs interpreter interpreted
Js interpreter interpreted
 
Ss dotnetcodexmpl
Ss dotnetcodexmplSs dotnetcodexmpl
Ss dotnetcodexmpl
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loop
 

Ähnlich wie オープンデータを使ったモバイルアプリ開発(応用編)

Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Gearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copyGearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copy
Brian Aker
 
Gearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copyGearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copy
Brian Aker
 

Ähnlich wie オープンデータを使ったモバイルアプリ開発(応用編) (20)

Angular2 rxjs
Angular2 rxjsAngular2 rxjs
Angular2 rxjs
 
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
RxJava on Android
RxJava on AndroidRxJava on Android
RxJava on Android
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8JavaScript Editions ES7, ES8 and ES9 vs V8
JavaScript Editions ES7, ES8 and ES9 vs V8
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
 
Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
How to practice functional programming in react
How to practice functional programming in reactHow to practice functional programming in react
How to practice functional programming in react
 
Call stack, event loop and async programming
Call stack, event loop and async programmingCall stack, event loop and async programming
Call stack, event loop and async programming
 
What's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritageWhat's in Kotlin for us - Alexandre Greschon, MyHeritage
What's in Kotlin for us - Alexandre Greschon, MyHeritage
 
Introductory RxJava
Introductory RxJavaIntroductory RxJava
Introductory RxJava
 
Gearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copyGearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copy
 
Gearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copyGearmam, from the_worker's_perspective copy
Gearmam, from the_worker's_perspective copy
 
Functional JavaScript for everyone
Functional JavaScript for everyoneFunctional JavaScript for everyone
Functional JavaScript for everyone
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
From Javascript To Haskell
From Javascript To HaskellFrom Javascript To Haskell
From Javascript To Haskell
 

Mehr von Takayuki Goto (7)

ros2_cmd_api : ROS2コマンド機能のAPIを提供するROS2パッケージ.pdf
ros2_cmd_api :  ROS2コマンド機能のAPIを提供するROS2パッケージ.pdfros2_cmd_api :  ROS2コマンド機能のAPIを提供するROS2パッケージ.pdf
ros2_cmd_api : ROS2コマンド機能のAPIを提供するROS2パッケージ.pdf
 
OculusのPassthrough APIを使ってみた
OculusのPassthrough APIを使ってみたOculusのPassthrough APIを使ってみた
OculusのPassthrough APIを使ってみた
 
WindowsではじめるROSプログラミング
WindowsではじめるROSプログラミングWindowsではじめるROSプログラミング
WindowsではじめるROSプログラミング
 
DockerでCKANを動かそう
DockerでCKANを動かそうDockerでCKANを動かそう
DockerでCKANを動かそう
 
オープンデータを使ったモバイルアプリ開発(入門編)
オープンデータを使ったモバイルアプリ開発(入門編)オープンデータを使ったモバイルアプリ開発(入門編)
オープンデータを使ったモバイルアプリ開発(入門編)
 
オープンデータを使った モバイルアプリ開発入門
オープンデータを使ったモバイルアプリ開発入門オープンデータを使ったモバイルアプリ開発入門
オープンデータを使った モバイルアプリ開発入門
 
Expoによるモバイルアプリ開発入門
Expoによるモバイルアプリ開発入門Expoによるモバイルアプリ開発入門
Expoによるモバイルアプリ開発入門
 

Kürzlich hochgeladen

Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
Health
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Kürzlich hochgeladen (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
+97470301568>> buy weed in qatar,buy thc oil qatar,buy weed and vape oil in d...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 

オープンデータを使ったモバイルアプリ開発(応用編)

  • 1. 1 20 1 8 ISIT 1
  • 2. ­ ­ ­ ­ ­ Expo Snack ­ UI React React ­ ­ ­ React ­ Expo SDK 2
  • 5. DECLARATIVE ­ ­ 5 (+ 1 2 3 4 5) ;15 var sum = function(arr){ var sum=0; for(var i=0; i < arr.length; i++){ sum += arr[i]; } return sum; } var arr = [1, 2, 3, 4, 5]; console.log( sum(arr) ); // 15 sum [1,2,3,4,5] --15
  • 6. 6 function double (arr) { let results = [] for (let i = 0; i < arr.length; i++){ results.push(arr[i] * 2) } return results } function double (arr) { return arr.map((item) => item * 2) } function add (arr) { let result = 0 for (let i = 0; i < arr.length; i++){ result += arr[i] } return result } function add (arr) { return arr.reduce((prev, current) => prev + current, 0) } $("#btn").click(function() { $(this).toggleClass("highlight") $(this).text() === 'Add Highlight' ? $(this).text('Remove Highlight') : $(this).text('Add Highlight') }) <Btn onToggleHighlight={this.handleToggleHighlight} highlight={this.state.highlight}> {this.state.buttonText} </Btn> https://tylermcginnis.com/imperative-vs-declarative-programming/
  • 7. CBD: Component-based development ­ separation of concerns ­ 7 https://en.wikipedia.org/wiki/Component-based_software_engineering https://medium.com/@dan.shapiro1210/understanding-component-based-architecture-3ff48ec0c238 • • •
  • 8. REACT 8 class Welcome extends React.Component { state = {name: 'Anzu'}; render() { return ( <div> <h1>Hello, {this.props.name}</h1> <div>My name is {this.state.name}</div> </div> ); } } class App extends React.Component { render() { return ( <div> <Welcome name="Taro" /> <Welcome name="Hanako" /> </div> ); } } View
  • 9. 9 function Welcome(props) { return <h1>Hello, {props.name}</h1>; } class Welcome extends React.Component { render() { return <h1>Hello, {this.props.name}</h1>; } } Functional • • • Functional
  • 11. LEARN ONCE, WRITE ANYWHERE Java ­ Write once, run anywhere ­ ­ React ­ iOS, android : React Native ­ Win, Mac React Desktop (https://reactdesktop.js.org/) 11https://reactjs.org/blog/2015/03/26/introducing-react-native.html
  • 12. ES2015 ECMASCRIPT2015 12 let let name = 'taro'; name = 'hanako' const const name = 'taro'; name = 'hanako'; // error class class Person { constructor(name){ this.name = name; } } const person = new Person('taro') const fn = (name) =>{ return console.log(name); } const arr = ['a', 'b', 'c']; const arr2 = [...arr]; console.log(arr === arr2); // false const name = 'taro'; console.log(`My name is ${name}.`); // My name is taro. https://babeljs.io/docs/en/learn/ Expo ES6 6th Edition
  • 13. extract(‘test.txt’, function(data1){ transform(data1, function(data2){ load(data2, function(data3){ console.log(‘done: ’, data3); }); }); }); var promise = Promise.resolve(); promise .then(()=> extract(‘text.txt’)); .then(data1=> transform(data1)) .then(data2=> load(data2)) .then((data3)=> console.log(‘done: , data3 ’)) async ()=>{ let data1 = await extract(‘test.txt’); let data2 = await transform(data1); let data3 = await load(data2); console.log(‘done: ’, data3); } ES5 13 ES2015(ES6) Promise, ES2017(ES8) async/await Expo ES8 async/await
  • 14. JSX JAVASCRIPT XML, JAVASCRIPT SYNTAX EXTENSION 14 XML JavaScript <MyButton color="blue" shadowSize={2}> Click Me </MyButton> React.createElement( MyButton, {color: 'blue', shadowSize: 2}, 'Click Me' ) <div className="sidebar" /> React.createElement( 'div', {className: 'sidebar'}, null ) https://reactjs.org/docs/introducing-jsx.html JSX React.createElement(component, props, ...children)
  • 15. DOM DOM ReactDOM DOM DOM React DOM 15 DOM DOM Key {todos.map((todo, index) => <Todo {...todo} key={index} /> )} {todos.map((todo) => <Todo {...todo} key={todo.id} /> )} ID var shortid = require('shortid'); function createNewTodo(text) { return { completed: false, id: shortid.generate(), text } } ID todoCounter = 1; function createNewTodo(text) { return { completed: false, id: todoCounter++, text } } https://reactjs.org/docs/faq-internals.html https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318 shortid ID
  • 17. EXPO SDK ­ Web ­ iOS, Android API ­ API API 17 Core Motion iOS Google Fit Android Pedometer (Expo SDK) API
  • 18. 18 AR Accelerometer Admob Amplitude AppLoading ART Asset Audio AuthSession Web AV BarCodeScanner BlurView Branch Brghtness Calendar Camera Constants ID Contacts DeviceMotion DocumentPicker ErrorRecovery FacebookAds Facebook Graph API FaceDetector FileSystem Font GestureHandler GLView OpenGL ES Google Google Gyroscope Haptic ImageManipulator ImagePicker IntentLauncherAndroid KeepAwake LinerGradient Linking LocalAuthentication Localization Location Lottie Magnetometer MailComposer MapView MediaLibrary Notifications Payments Pedometer Permissions Print registerRootComponent ScreenOrientation SecureStore Segment SMS Speech SplashScreen SQLite StoreReview Svg SVG takeSnapshotAsync Updates Video WebBrowser
  • 20. LOCATION 20 let { status } = await Permissions.askAsync(Permissions.LOCATION); if (status !== 'granted’) console.log('Permission to access location was denied'); Permissions API let location = await Location.getCurrentPositionAsync({}); // address = await Location.reverseGeocodeAsync(loc) // Location.watchHeadingAsync(this._getHeadingAsync) // //
  • 21. PEDOMETER Core Motion iOS Google Fit Android 21 Expo.Pedometer.isAvailableAsync() Expo.Pedometer.getStepCountAsync(start, end) Expo.Pedometer.watchStepCount(callback) https://snack.expo.io/@tygoto/pedometer
  • 22. PEDOMETER 22 componentDidMount() { this._subscription = Pedometer.watchStepCount(result => { this.setState({ currentStepCount: result.steps, }); }); } componentWillUnmount() { this._subscription && this._subscription.remove(); this._subscription = null; } Pedometer.getStepCountAsync
  • 24. CAMERA 24 Camera.Constants.Type.back front ref={ref => { this.cameraRef = ref; }}> let photo = await this.cameraRef.takePictureAsync();
  • 25. OPEN DATA EXPO SDK 25
  • 26. OPEN DATA EXPO SDK http://data.bodik.jp/dataset ­ ­ http://data.bodik.jp/dataset/atmospheric48 ­ ­ http://data.bodik.jp/dataset/401000_koutsuujiko2017 ­ ­ ­ ­ Expo SDK 26
  • 28. React ­ ­ ES2015, JSX, DOM Expo SDK Expo SDK API Open Data Expo SDK ­ Expo SDK ­ 28