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

PDF
Lecture 2: ES6 / ES2015 Slide
PDF
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
PDF
React Native Firebase
PDF
React Native Firebase Realtime Database + Authentication
PDF
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
PDF
Intro To React Native
PDF
Ryan Christiani I Heard React Was Good
PDF
Introduction to React Native
Lecture 2: ES6 / ES2015 Slide
[React Native] Lecture 4: Basic Elements and UI Layout by using FlexBox
React Native Firebase
React Native Firebase Realtime Database + Authentication
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
Intro To React Native
Ryan Christiani I Heard React Was Good
Introduction to React Native

What's hot (20)

PDF
An Overview of the React Ecosystem
PDF
React Native custom components
PPT
PDF
Introduction to React Native & Redux
PDF
Developing, building, testing and deploying react native apps
PDF
JOSA TechTalks - RESTful API Concepts and Best Practices
PDF
JOSA TechTalks - Better Web Apps with React and Redux
PPTX
Introduction to angular 2
PDF
React && React Native workshop
PDF
Some experiences building an Android app with React Native & Redux
PDF
React Native +Redux + ES6 (Updated)
PPSX
React introduction
PDF
Angular2 Development for Java developers
PPTX
React js - The Core Concepts
PPTX
Setting Up Development Environment For Google App Engine & Python | Talentica
PPTX
React js
PPTX
React js
PDF
Angular 2 Essential Training
PPTX
React Native: Introduction
An Overview of the React Ecosystem
React Native custom components
Introduction to React Native & Redux
Developing, building, testing and deploying react native apps
JOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - Better Web Apps with React and Redux
Introduction to angular 2
React && React Native workshop
Some experiences building an Android app with React Native & Redux
React Native +Redux + ES6 (Updated)
React introduction
Angular2 Development for Java developers
React js - The Core Concepts
Setting Up Development Environment For Google App Engine & Python | Talentica
React js
React js
Angular 2 Essential Training
React Native: Introduction
Ad

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

PDF
Getting Started with React, When You’re an Angular Developer
PDF
Angular2 with type script
PPTX
O365 Developer Bootcamp NJ 2018 - Material
PPTX
Intro to appcelerator
PDF
Full Stack React Workshop [CSSC x GDSC]
PDF
From MEAN to the MERN Stack
PPT
Spring - a framework written by developers
PPTX
Adding a modern twist to legacy web applications
PPTX
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
PPTX
20180518 QNAP Seminar - Introduction to React Native
PDF
react hook and wesite making structure ppt
PDF
Mobx Internals
PDF
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
PPTX
Introduction to react native with redux
PPTX
React Basic and Advance || React Basic
PPTX
React JS: A Secret Preview
PPTX
Reactjs notes.pptx for web development- tutorial and theory
PDF
From Backbone to Ember and Back(bone) Again
PPTX
04 integrate entityframework
PDF
React state management with Redux and MobX
Getting Started with React, When You’re an Angular Developer
Angular2 with type script
O365 Developer Bootcamp NJ 2018 - Material
Intro to appcelerator
Full Stack React Workshop [CSSC x GDSC]
From MEAN to the MERN Stack
Spring - a framework written by developers
Adding a modern twist to legacy web applications
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
20180518 QNAP Seminar - Introduction to React Native
react hook and wesite making structure ppt
Mobx Internals
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Introduction to react native with redux
React Basic and Advance || React Basic
React JS: A Secret Preview
Reactjs notes.pptx for web development- tutorial and theory
From Backbone to Ember and Back(bone) Again
04 integrate entityframework
React state management with Redux and MobX
Ad

More from Kobkrit Viriyayudhakorn (20)

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

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Strategies for Manufacturing Companies
PDF
AI in Product Development-omnex systems
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
history of c programming in notes for students .pptx
PPTX
Introduction to Artificial Intelligence
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
medical staffing services at VALiNTRY
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PTS Company Brochure 2025 (1).pdf.......
Digital Strategies for Manufacturing Companies
AI in Product Development-omnex systems
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Understanding Forklifts - TECH EHS Solution
history of c programming in notes for students .pptx
Introduction to Artificial Intelligence
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How Creative Agencies Leverage Project Management Software.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
How to Choose the Right IT Partner for Your Business in Malaysia
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
medical staffing services at VALiNTRY

[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