SlideShare a Scribd company logo
Kobkrit Viriyayudhakorn, Ph.D.
CEO of iApp Technology Limited.
kobkrit@gmail.com
http://www.kobkrit.com
Making Stocks App
1. Draw UI on Paper
2. Initial project using react-native
1. $|> react-native init
stock
3. Making UI
4. Making Styles
5. Input Handling
6. Fetch Data from Network
7. Output
Making UI
• Make a View have
style.container fill the full
screen
• Split them two 2 parts equally,
header and footer (yellow and
pink part)
• Yellow part, set every thing on
center
• Pink part, have
flexDirection: ‘row’
and flexWrap: ‘wrap’
Index.js
Index.js
React’s Component
• React is fundamentally designed for component-
based programming.
• Build encapsulated components that manage their
own state, then compose them to make complex
UIs application.
• A Component can have many children components.
• Communication from parent to children components
can be done via Props.
• We have 9 buttons for 

stock codes. (A button is 

highlighted on the left)
• Many duplicated 

elements should

make it as a Component.
• Don’t Repeat Yourself!

(DRY) principle.
Make Repeat Elements As

Components
Hello StockButton!
• Create a new file named
‘StockButton.js’ located in the
same directory of the project.
• StockButton is a component for
represent a Stock Index button at
the lower half of the app.
• After we complete the
StockButton component, we will
import and use it as a part of the
main Stock application
component.
StockButton
StockButton.js
Including StockButton
Components in Main App.
Index.js
Adding ChangeIndex
method
Index.js
Push A Button &

See Action in
Remote
Debugger
Props
• Communication from parent to child components.
• It can be done by using attributes values, and/or callback
functions.
• Callback functions allows the child components to

communicate back to the parents.
Attribute Value
A Callback Function
Callback FunctionAttribute Value
A Callback Function
Index Component
StockButton Component
this.

props
A Callback Function
Index Component
StockButton Component
When User Press a Button
SET INDEXBKK:SET
Getting Stock Information
Google Finance
https://google.com/finance
Getting Index Codes
Getting JSON information of
a market index
• Google Finance have internal API for getting finance
information in JSON format.
• https://www.google.com/finance/info?q=STOCKCODE
• For Example, https://www.google.com/finance/info?
q=SHA%3A000001
JSON Explain
• // Invalid JSON Syntax (Need to Remove).
• "l" : “3,022.37" Stock Index
• "c" : “-3.69” Stock Index Change (Raw number)
• "cp" : “-0.12" Stock Index Change (Percentage)
// [ { "id": "7521596" ,"t" : "000001" ,"e" : "SHA" ,"l" :
"3,022.37" ,"l_fix" : "3022.37" ,"l_cur" : "CN¥3,022.37" ,"s":
"0" ,"ltt":"11:17AM GMT+8" ,"lt" : "Sep 20, 11:17AM
GMT+8" ,"lt_dts" : "2016-09-20T11:17:25Z" ,"c" : "-3.69" ,"c_fix"
: "-3.69" ,"cp" : "-0.12" ,"cp_fix" : "-0.12" ,"ccol" : "chr" ,"pcls_fix"
: "3026.0513" } ]
API Module
• Create a new file named ‘api.js’ located in the same
directory of the project.
• Export as the default function that getting Stock
information from the Google Finance
• Main app (Index.js) will imported that API module
and using it in the changeStock method.
api.js
Fetch API
• The Fetch API provides an interface for fetching
resources (including across the network).
• It is a living standard in Web Hypertext Application
Technology Working Group (WHATWG)
• Syntax:
// Resolve response as Blob
// Resolve response as JSON
// Resolve response as Text
.then Promise
• .then promise is a kind of advance technique of
chaining callback function.
• .then promise will be invoked when the earlier
operation is completed.
// (1) Fetching from URL
// (2) Wait until fetching

is finished, then convert 

response data to text format.
// (3) Wait until the data

conversion is finished, then,
using the data.
.catch Promise
• In cases of fetching errors, such as, Internet connection down,the
URL is no longer exist, etc. How can we resolve it?
• .catch promise can be added at the end of any promise to capture
any errors in the promise. The code interpreter will jump from the
point of the error occur to the functions in .catch Promise.
api.js
// Invalid JSON Syntax (Need to Remove).
"l" : “3,022.37" Stock Index
"c" : “-3.69” Stock Index Change (Raw
number)
"cp" : “-0.12" Stock Index Change
(Percentage)
Output the value
• Set up state for displaying the value.
• Set up initial state.
[React Native Tutorial] Lecture 6: Component, Props, and Network
Update State
Press
Making Initial Loading
• Add this.changeIndex at the constructor
Adding Red / Green 

Text Color
[React Native Tutorial] Lecture 6: Component, Props, and Network
Homework
• Make the Stock application that can view the USA
Tech Stock Markets
• Apple: AAPL
• Google: GOOG
• Microsoft: MSFT
• Facebook: FB
• Alibaba: BABA

More Related Content

What's hot (20)

PDF
An Overview of the React Ecosystem
FITC
 
PDF
React Native custom components
Jeremy Grancher
 
PPT
React native
Mohammed El Rafie Tarabay
 
PDF
Introduction to React Native & Redux
Barak Cohen
 
PDF
Developing, building, testing and deploying react native apps
Leena N
 
PDF
JOSA TechTalks - RESTful API Concepts and Best Practices
Jordan Open Source Association
 
PDF
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
PPTX
Introduction to angular 2
Dor Moshe
 
PDF
React && React Native workshop
Stacy Goh
 
PDF
Some experiences building an Android app with React Native & Redux
Alex Bepple
 
PDF
React Native +Redux + ES6 (Updated)
Chiew Carol
 
PPSX
React introduction
Kashyap Parmar
 
PDF
Angular2 Development for Java developers
Yakov Fain
 
PPTX
React js - The Core Concepts
Divyang Bhambhani
 
PPTX
Setting Up Development Environment For Google App Engine & Python | Talentica
Talentica Software
 
PPTX
React js
Alireza Akbari
 
PPTX
React js
Nikhil Karkra
 
PDF
Angular 2 Essential Training
Patrick Schroeder
 
PPTX
React Native: Introduction
InnerFood
 
An Overview of the React Ecosystem
FITC
 
React Native custom components
Jeremy Grancher
 
Introduction to React Native & Redux
Barak Cohen
 
Developing, building, testing and deploying react native apps
Leena N
 
JOSA TechTalks - RESTful API Concepts and Best Practices
Jordan Open Source Association
 
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
Introduction to angular 2
Dor Moshe
 
React && React Native workshop
Stacy Goh
 
Some experiences building an Android app with React Native & Redux
Alex Bepple
 
React Native +Redux + ES6 (Updated)
Chiew Carol
 
React introduction
Kashyap Parmar
 
Angular2 Development for Java developers
Yakov Fain
 
React js - The Core Concepts
Divyang Bhambhani
 
Setting Up Development Environment For Google App Engine & Python | Talentica
Talentica Software
 
React js
Alireza Akbari
 
React js
Nikhil Karkra
 
Angular 2 Essential Training
Patrick Schroeder
 
React Native: Introduction
InnerFood
 

Similar to [React Native Tutorial] Lecture 6: Component, Props, and Network (20)

PDF
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
PDF
Angular2 with type script
Ravi Mone
 
PPTX
O365 Developer Bootcamp NJ 2018 - Material
Thomas Daly
 
PPTX
Intro to appcelerator
Mohab El-Shishtawy
 
PDF
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PPT
Spring - a framework written by developers
MarcioSoaresPereira1
 
PPTX
Adding a modern twist to legacy web applications
Jeff Durta
 
PPTX
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Gil Irizarry
 
PPTX
20180518 QNAP Seminar - Introduction to React Native
Eric Deng
 
PDF
Mobx Internals
500Tech
 
PDF
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Luis Cruz
 
PPTX
Introduction to react native with redux
Mike Melusky
 
PPTX
React Basic and Advance || React Basic
rafaqathussainc077
 
PPTX
React JS: A Secret Preview
valuebound
 
PPTX
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
PDF
From Backbone to Ember and Back(bone) Again
jonknapp
 
PPTX
04 integrate entityframework
Erhwen Kuo
 
PDF
React state management with Redux and MobX
Darko Kukovec
 
PPTX
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Angular2 with type script
Ravi Mone
 
O365 Developer Bootcamp NJ 2018 - Material
Thomas Daly
 
Intro to appcelerator
Mohab El-Shishtawy
 
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
From MEAN to the MERN Stack
Troy Miles
 
Spring - a framework written by developers
MarcioSoaresPereira1
 
Adding a modern twist to legacy web applications
Jeff Durta
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Gil Irizarry
 
20180518 QNAP Seminar - Introduction to React Native
Eric Deng
 
Mobx Internals
500Tech
 
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Luis Cruz
 
Introduction to react native with redux
Mike Melusky
 
React Basic and Advance || React Basic
rafaqathussainc077
 
React JS: A Secret Preview
valuebound
 
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 
From Backbone to Ember and Back(bone) Again
jonknapp
 
04 integrate entityframework
Erhwen Kuo
 
React state management with Redux and MobX
Darko Kukovec
 
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
Ad

More from Kobkrit Viriyayudhakorn (20)

PDF
Thai E-Voting System
Kobkrit Viriyayudhakorn
 
PPTX
Thai National ID Card OCR
Kobkrit Viriyayudhakorn
 
PPTX
Chochae Robot - Thai voice communication extension pack for Service Robot
Kobkrit Viriyayudhakorn
 
PDF
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
Kobkrit Viriyayudhakorn
 
PDF
Thai Text processing by Transfer Learning using Transformer (Bert)
Kobkrit Viriyayudhakorn
 
PDF
How Emoticon Affects Chatbot Users
Kobkrit Viriyayudhakorn
 
PPTX
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
Kobkrit Viriyayudhakorn
 
PDF
Check Raka Chatbot Pitching Presentation
Kobkrit Viriyayudhakorn
 
PPTX
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
Kobkrit Viriyayudhakorn
 
PPTX
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
Kobkrit Viriyayudhakorn
 
PPTX
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
Kobkrit Viriyayudhakorn
 
PDF
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
Kobkrit Viriyayudhakorn
 
PDF
Lecture 12: React-Native Firebase Authentication
Kobkrit Viriyayudhakorn
 
PDF
Unity Google VR Cardboard Deployment on iOS and Android
Kobkrit Viriyayudhakorn
 
PDF
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
Kobkrit Viriyayudhakorn
 
PDF
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Kobkrit Viriyayudhakorn
 
PDF
Lecture 2: C# Programming for VR application in Unity
Kobkrit Viriyayudhakorn
 
PDF
Lecture 1 Introduction to VR Programming
Kobkrit Viriyayudhakorn
 
PDF
Thai Word Embedding with Tensorflow
Kobkrit Viriyayudhakorn
 
PDF
Lecture 3 - ES6 Script Advanced for React-Native
Kobkrit Viriyayudhakorn
 
Thai E-Voting System
Kobkrit Viriyayudhakorn
 
Thai National ID Card OCR
Kobkrit Viriyayudhakorn
 
Chochae Robot - Thai voice communication extension pack for Service Robot
Kobkrit Viriyayudhakorn
 
ศักยภาพของ AI สู่โอกาสใหม่แห่งการแข่งขันและความสำเร็จ (Thai AI updates in yea...
Kobkrit Viriyayudhakorn
 
Thai Text processing by Transfer Learning using Transformer (Bert)
Kobkrit Viriyayudhakorn
 
How Emoticon Affects Chatbot Users
Kobkrit Viriyayudhakorn
 
หัวใจของปัญญาประดิษฐ์ (Gradient Descent ทำงานอย่างไร)
Kobkrit Viriyayudhakorn
 
Check Raka Chatbot Pitching Presentation
Kobkrit Viriyayudhakorn
 
[Lecture 3] AI and Deep Learning: Logistic Regression (Coding)
Kobkrit Viriyayudhakorn
 
[Lecture 4] AI and Deep Learning: Neural Network (Theory)
Kobkrit Viriyayudhakorn
 
[Lecture 2] AI and Deep Learning: Logistic Regression (Theory)
Kobkrit Viriyayudhakorn
 
ITS488 Lecture 6: Music and Sound Effect & GVR Try out.
Kobkrit Viriyayudhakorn
 
Lecture 12: React-Native Firebase Authentication
Kobkrit Viriyayudhakorn
 
Unity Google VR Cardboard Deployment on iOS and Android
Kobkrit Viriyayudhakorn
 
ITS488 Lecture 4: Google VR Cardboard Game Development: Basket Ball Game #2
Kobkrit Viriyayudhakorn
 
Lecture 4: ITS488 Digital Content Creation with Unity - Game and VR Programming
Kobkrit Viriyayudhakorn
 
Lecture 2: C# Programming for VR application in Unity
Kobkrit Viriyayudhakorn
 
Lecture 1 Introduction to VR Programming
Kobkrit Viriyayudhakorn
 
Thai Word Embedding with Tensorflow
Kobkrit Viriyayudhakorn
 
Lecture 3 - ES6 Script Advanced for React-Native
Kobkrit Viriyayudhakorn
 
Ad

Recently uploaded (20)

PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 

[React Native Tutorial] Lecture 6: Component, Props, and Network

  • 1. Kobkrit Viriyayudhakorn, Ph.D. CEO of iApp Technology Limited. [email protected] http://www.kobkrit.com
  • 2. Making Stocks App 1. Draw UI on Paper 2. Initial project using react-native 1. $|> react-native init stock 3. Making UI 4. Making Styles 5. Input Handling 6. Fetch Data from Network 7. Output
  • 3. Making UI • Make a View have style.container fill the full screen • Split them two 2 parts equally, header and footer (yellow and pink part) • Yellow part, set every thing on center • Pink part, have flexDirection: ‘row’ and flexWrap: ‘wrap’
  • 6. React’s Component • React is fundamentally designed for component- based programming. • Build encapsulated components that manage their own state, then compose them to make complex UIs application. • A Component can have many children components. • Communication from parent to children components can be done via Props.
  • 7. • We have 9 buttons for 
 stock codes. (A button is 
 highlighted on the left) • Many duplicated 
 elements should
 make it as a Component. • Don’t Repeat Yourself!
 (DRY) principle. Make Repeat Elements As
 Components
  • 8. Hello StockButton! • Create a new file named ‘StockButton.js’ located in the same directory of the project. • StockButton is a component for represent a Stock Index button at the lower half of the app. • After we complete the StockButton component, we will import and use it as a part of the main Stock application component. StockButton
  • 12. Push A Button &
 See Action in Remote Debugger
  • 13. Props • Communication from parent to child components. • It can be done by using attributes values, and/or callback functions. • Callback functions allows the child components to
 communicate back to the parents. Attribute Value A Callback Function Callback FunctionAttribute Value
  • 14. A Callback Function Index Component StockButton Component this.
 props
  • 15. A Callback Function Index Component StockButton Component When User Press a Button SET INDEXBKK:SET
  • 16. Getting Stock Information Google Finance https://google.com/finance
  • 18. Getting JSON information of a market index • Google Finance have internal API for getting finance information in JSON format. • https://www.google.com/finance/info?q=STOCKCODE • For Example, https://www.google.com/finance/info? q=SHA%3A000001
  • 19. JSON Explain • // Invalid JSON Syntax (Need to Remove). • "l" : “3,022.37" Stock Index • "c" : “-3.69” Stock Index Change (Raw number) • "cp" : “-0.12" Stock Index Change (Percentage) // [ { "id": "7521596" ,"t" : "000001" ,"e" : "SHA" ,"l" : "3,022.37" ,"l_fix" : "3022.37" ,"l_cur" : "CN¥3,022.37" ,"s": "0" ,"ltt":"11:17AM GMT+8" ,"lt" : "Sep 20, 11:17AM GMT+8" ,"lt_dts" : "2016-09-20T11:17:25Z" ,"c" : "-3.69" ,"c_fix" : "-3.69" ,"cp" : "-0.12" ,"cp_fix" : "-0.12" ,"ccol" : "chr" ,"pcls_fix" : "3026.0513" } ]
  • 20. API Module • Create a new file named ‘api.js’ located in the same directory of the project. • Export as the default function that getting Stock information from the Google Finance • Main app (Index.js) will imported that API module and using it in the changeStock method.
  • 22. Fetch API • The Fetch API provides an interface for fetching resources (including across the network). • It is a living standard in Web Hypertext Application Technology Working Group (WHATWG) • Syntax: // Resolve response as Blob // Resolve response as JSON // Resolve response as Text
  • 23. .then Promise • .then promise is a kind of advance technique of chaining callback function. • .then promise will be invoked when the earlier operation is completed. // (1) Fetching from URL // (2) Wait until fetching
 is finished, then convert 
 response data to text format. // (3) Wait until the data
 conversion is finished, then, using the data.
  • 24. .catch Promise • In cases of fetching errors, such as, Internet connection down,the URL is no longer exist, etc. How can we resolve it? • .catch promise can be added at the end of any promise to capture any errors in the promise. The code interpreter will jump from the point of the error occur to the functions in .catch Promise.
  • 25. api.js // Invalid JSON Syntax (Need to Remove). "l" : “3,022.37" Stock Index "c" : “-3.69” Stock Index Change (Raw number) "cp" : “-0.12" Stock Index Change (Percentage)
  • 26. Output the value • Set up state for displaying the value. • Set up initial state.
  • 29. Press
  • 30. Making Initial Loading • Add this.changeIndex at the constructor
  • 31. Adding Red / Green 
 Text Color
  • 33. Homework • Make the Stock application that can view the USA Tech Stock Markets • Apple: AAPL • Google: GOOG • Microsoft: MSFT • Facebook: FB • Alibaba: BABA