ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
REACT NATIVE
Build Native iOS Applications with Javascript
FOLLOW ALONG!
github.com/scottcrespo/reactnativedemo
JAVASCRIPT REFRESHER
Anything Seem Unfamiliar?
? Lexical Scope: this, call(), apply() bind(),
? ECMAScript 6 Classes
? Arrow Functions: (x, y) => { statements }
? Node npm
WHAT IS REACT NATIVE?
? Modern Javascript Framework
? Acts as an API/wrapper to native iOS
modules
? Uses XML-style syntax
MANY NATIVE
COMPONENTS
? ActivityIndicatorIOS
? DatePickerIOS
? Image
? ListView
? MapView
? Navigator
? NavigatorIOS
? PickerIOS
? ScrollView
? SegmentedControlI
OS
? ºÝºÝߣrIOS
? SwitchIOS
? TabBarIOS
? TabBarIOS.Item
? Text
? TextInput
? TouchableHighlight
? TouchableOpacity
? TouchableWithoutFe
edback
? View
? WebView
SWEET APIS
? ActionSheetIOS
? AlertIOS
? AppRegistry
? AppStateIOS
? AsyncStorage
? CameraRoll
? InteractionMana
ger
? LayoutAnimation
? LinkingIOS
? NetInfo
? PanResponder
? PixelRatio
? PushNotificationI
OS
? StatusBarIOS
? StyleSheet
? VibrationIOS
UNDER THE HOOD
Native Thread
Javascript Thread
Process
HELLO REACT NATIVE
// imports omitted
ReactNativeDemo extends React.Component{
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Hello React Native!
</Text>
</View>
);
}
}
AppRegistry.registerComponent('ReactNativeDemo', () => ReactNativeDemo);
REACT
CORE
CONCEPTS
Master
COMPONENT TREE
Child1
Child2 Child3 Child4
Controls StateProps Callbacks
EXAMPLE 1
Render Multiple Components
Master
Child1
Child2
MASTER
class ReactNativeDemo extends React.Component {
render() {
return (
<View style={styles.container} >
<Text>
Master Text
</Text>
<Child1 />
</View>
);
}
}
CHILD1
class Child1 extends React.Component {
render() {
return(
<View>
<Text style={styles.lrgtxt}>
Child1 Text
</Text>
<Child2 />
</View>
);
}
}
CHILD2
class Child2 extends React.Component {
render() {
return(
<View>
<Text style={styles.lrgtxt}>
Child2 Text
</Text>
</View>
);
}
}
EXAMPLE 2
Passing Data (Props) Down the Component Tree
Master
Child1
Child2
message
message
MASTER
class ReactNativeDemo extends React.Component {
render() {
let message = "Child2 Message";
return (
<View style={styles.container} >
<Text style={styles.lrgtxt}>
Master Text
</Text>
<Child1 message={message} />
</View>
);
}
}
CHILD1
class Child1 extends React.Component {
render() {
return(
<View>
<Text style={styles.lrgtxt}>
Child1 Text
</Text>
<Child2 message={this.props.message}/>
</View>
);
}
}
CHILD2
class Child2 extends React.Component {
render() {
return(
<View>
<Text style={styles.lrgtxt}>
Child2 Text
</Text>
<Text>
{this.props.message}
</Text>
</View>
);
}
}
EXAMPLE 3
Changing State With Callbacks
Master
Child1
Child2
message
onUserInput
message
onUserInput
onUserInput(msg)
onUserInput(msg)
MASTER PT.1
Managing State
constructor() {
super();
this.handlePressMessage = this.handlePressMessage.bind(this);
this.state = { message : "Initial Message", messagenum : 0,
};
}
handlePressMessage(msg) {
if (this.state.messagenum === 0) {
this.setState({message : msg, messagenum: 1});
}
else {
this.setState({message: "Inital Message", messagenum: 0});
}
}
MASTER PT.2
Rendering
render() {
return (
<View style={styles.container} >
<Text style={styles.lrgtxt}>
Master Text
</Text>
<Child1
message={this.state.message}
onUserInput={this.handlePressMessage}
/>
</View>
);
}
CHILD1
Passing Along Callback as Props
class Child1 extends React.Component {
render() {
return(
<View>
<Text style={styles.lrgtxt}>
Child1 Text
</Text>
<Child2
message={this.props.message}
onUserInput={this.props.onUserInput}
/>
</View>
);
}
}
CHILD2
React to onPress Event Using Native Component
handleChange() {
var msg = "New Message!";
this.props.onUserInput(msg);
}
render() {
return(
<View>
<Text style={styles.lrgtxt}>
Child2 Text
</Text>
<Text>
Message: {this.props.message}
</Text>
<TouchableHighlight onPress={this.handleChange.bind(this)}>
<Text style={{fontWeight:'bold',}}>
Click to change message
</Text>
</TouchableHighlight>
</View>
);
}
THANK YOU!
Scott Crespo
scott@orlandods.com
github.com/scottcrespo

More Related Content

Featured (20)

2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design ProcessStorytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition ¨C SCHREPEL ¨C June 2024 OECD dis...
Artificial Intelligence, Data and Competition ¨C SCHREPEL ¨C June 2024 OECD dis...Artificial Intelligence, Data and Competition ¨C SCHREPEL ¨C June 2024 OECD dis...
Artificial Intelligence, Data and Competition ¨C SCHREPEL ¨C June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report ¨C by Hubspot
2024 State of Marketing Report ¨C by Hubspot2024 State of Marketing Report ¨C by Hubspot
2024 State of Marketing Report ¨C by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design ProcessStorytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report ¨C by Hubspot
2024 State of Marketing Report ¨C by Hubspot2024 State of Marketing Report ¨C by Hubspot
2024 State of Marketing Report ¨C by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?

React Native - Introductory Tutorial

  • 1. REACT NATIVE Build Native iOS Applications with Javascript
  • 3. JAVASCRIPT REFRESHER Anything Seem Unfamiliar? ? Lexical Scope: this, call(), apply() bind(), ? ECMAScript 6 Classes ? Arrow Functions: (x, y) => { statements } ? Node npm
  • 4. WHAT IS REACT NATIVE? ? Modern Javascript Framework ? Acts as an API/wrapper to native iOS modules ? Uses XML-style syntax
  • 5. MANY NATIVE COMPONENTS ? ActivityIndicatorIOS ? DatePickerIOS ? Image ? ListView ? MapView ? Navigator ? NavigatorIOS ? PickerIOS ? ScrollView ? SegmentedControlI OS ? ºÝºÝߣrIOS ? SwitchIOS ? TabBarIOS ? TabBarIOS.Item ? Text ? TextInput ? TouchableHighlight ? TouchableOpacity ? TouchableWithoutFe edback ? View ? WebView
  • 6. SWEET APIS ? ActionSheetIOS ? AlertIOS ? AppRegistry ? AppStateIOS ? AsyncStorage ? CameraRoll ? InteractionMana ger ? LayoutAnimation ? LinkingIOS ? NetInfo ? PanResponder ? PixelRatio ? PushNotificationI OS ? StatusBarIOS ? StyleSheet ? VibrationIOS
  • 7. UNDER THE HOOD Native Thread Javascript Thread Process
  • 8. HELLO REACT NATIVE // imports omitted ReactNativeDemo extends React.Component{ render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Hello React Native! </Text> </View> ); } } AppRegistry.registerComponent('ReactNativeDemo', () => ReactNativeDemo);
  • 10. Master COMPONENT TREE Child1 Child2 Child3 Child4 Controls StateProps Callbacks
  • 11. EXAMPLE 1 Render Multiple Components Master Child1 Child2
  • 12. MASTER class ReactNativeDemo extends React.Component { render() { return ( <View style={styles.container} > <Text> Master Text </Text> <Child1 /> </View> ); } }
  • 13. CHILD1 class Child1 extends React.Component { render() { return( <View> <Text style={styles.lrgtxt}> Child1 Text </Text> <Child2 /> </View> ); } }
  • 14. CHILD2 class Child2 extends React.Component { render() { return( <View> <Text style={styles.lrgtxt}> Child2 Text </Text> </View> ); } }
  • 15. EXAMPLE 2 Passing Data (Props) Down the Component Tree Master Child1 Child2 message message
  • 16. MASTER class ReactNativeDemo extends React.Component { render() { let message = "Child2 Message"; return ( <View style={styles.container} > <Text style={styles.lrgtxt}> Master Text </Text> <Child1 message={message} /> </View> ); } }
  • 17. CHILD1 class Child1 extends React.Component { render() { return( <View> <Text style={styles.lrgtxt}> Child1 Text </Text> <Child2 message={this.props.message}/> </View> ); } }
  • 18. CHILD2 class Child2 extends React.Component { render() { return( <View> <Text style={styles.lrgtxt}> Child2 Text </Text> <Text> {this.props.message} </Text> </View> ); } }
  • 19. EXAMPLE 3 Changing State With Callbacks Master Child1 Child2 message onUserInput message onUserInput onUserInput(msg) onUserInput(msg)
  • 20. MASTER PT.1 Managing State constructor() { super(); this.handlePressMessage = this.handlePressMessage.bind(this); this.state = { message : "Initial Message", messagenum : 0, }; } handlePressMessage(msg) { if (this.state.messagenum === 0) { this.setState({message : msg, messagenum: 1}); } else { this.setState({message: "Inital Message", messagenum: 0}); } }
  • 21. MASTER PT.2 Rendering render() { return ( <View style={styles.container} > <Text style={styles.lrgtxt}> Master Text </Text> <Child1 message={this.state.message} onUserInput={this.handlePressMessage} /> </View> ); }
  • 22. CHILD1 Passing Along Callback as Props class Child1 extends React.Component { render() { return( <View> <Text style={styles.lrgtxt}> Child1 Text </Text> <Child2 message={this.props.message} onUserInput={this.props.onUserInput} /> </View> ); } }
  • 23. CHILD2 React to onPress Event Using Native Component handleChange() { var msg = "New Message!"; this.props.onUserInput(msg); } render() { return( <View> <Text style={styles.lrgtxt}> Child2 Text </Text> <Text> Message: {this.props.message} </Text> <TouchableHighlight onPress={this.handleChange.bind(this)}> <Text style={{fontWeight:'bold',}}> Click to change message </Text> </TouchableHighlight> </View> ); }