SlideShare a Scribd company logo
September 2018
Introduction to

React Native
Nacho Martín
Nacho Martin
I write code at Limenius.
We build tailor-made projects,
and provide consultancy
and formation.
We are very happy with React and React Native.
https://github.com/Limenius/workshop-react-native.git
Before we start
🙏
Please go to where you have cloned the repo
of the project
And run git fetch
Goal of the workshop
To be able to estimate how long would
it take you to create a first React Native
project (and if you would enjoy it)
Roadmap:
What is React Native
Starting a project
Working with Styles
Layout
Lists
Navigation
Networking
Touching the native side
What is React Native?
Fundamental premise of React
Give me a state and a render() method
that depends on it and forget about
how and when to render.
render() {
return (
<div className="App">
<button onClick={this.tick}>Click me!</button>
<span>Clicks: {this.state.count}</span>
</div>
)
}
render() {
return (
<div className="App">
<button onClick={this.tick}>Click me!</button>
<span>Clicks: {this.state.count}</span>
</div>
)
}
render() {
return (
<View style={…}>
<Button onPress={this.tick}>Click me!</Button>
<Text>Clicks: {this.state.count}</Text>
</View>
)
}
render() {
return (
<div className="App">
<button onClick={this.tick}>Click me!</button>
<span>Clicks: {this.state.count}</span>
</div>
)
}
render() {
return (
<View style={…}>
<Button onPress={this.tick}>Click me!</Button>
<Text>Clicks: {this.state.count}</Text>
</View>
)
}
render() {
return (
<div className="App">
<button onClick={this.tick}>Click me!</button>
<span>Clicks: {this.state.count}</span>
</div>
)
}
render() {
return (
<View style={…}>
<Button onPress={this.tick}>Click me!</Button>
<Text>Clicks: {this.state.count}</Text>
</View>
)
}
React Native
How is this possible
Reconciliation
Determines what parts
of the tree have changed
How is this possible
Reconciliation
Determines what parts
of the tree have changed
Rendering
Actually
updates the app
How is this possible
Reconciliation
Determines what parts
of the tree have changed
Rendering
Actually
updates the app
We can have several
renderers
React targets
Main
react-dom react-native
Web iOS android
React targets
Main
react-dom react-native
Web iOS android
But also
React targets
Main
react-dom react-native
Web iOS android
But also
react-art  react-canvas react-three ReactLibertyreact-worker-dom
React targets
Main
react-dom react-native
Web iOS android
But also
react-art  react-canvas react-three ReactLibertyreact-worker-dom
react-konsul raxreact-native  react-blessedreact-tvml
React targets
Main
react-dom react-native
Web iOS android
But also
react-art  react-canvas react-three ReactLibertyreact-worker-dom
react-konsul raxreact-native  react-blessedreact-tvml
React-GLreact-vr  react-hardware react-fs-renderer react-x11
React targets
Main
react-dom react-native
Web iOS android
But also
react-art  react-canvas react-three ReactLibertyreact-worker-dom
react-konsul raxreact-native  react-blessedreact-tvml
React-GLreact-vr  react-hardware react-fs-renderer react-x11
redocx react-titanium  React-Gibbon react-pdf  react-test-renderer
React targets
Main
react-dom react-native
Web iOS android
But also
react-art  react-canvas react-three ReactLibertyreact-worker-dom
react-konsul raxreact-native  react-blessedreact-tvml
React-GLreact-vr  react-hardware react-fs-renderer react-x11
redocx react-titanium  React-Gibbon react-pdf  react-test-renderer
ink  react-sketchapp 
React targets
Main
react-dom react-native
Web iOS android
But also
react-art  react-canvas react-three ReactLibertyreact-worker-dom
react-konsul raxreact-native  react-blessedreact-tvml
React-GLreact-vr  react-hardware react-fs-renderer react-x11
redocx react-titanium  React-Gibbon react-pdf  react-test-renderer
ink  react-sketchapp 
And more
React blessed
React blessed
React Sketch.app
React VR
Demo
How Native is React Native?
JS Thread
Business logic &
Description of what
components to render
How Native is React Native?
JS Thread Main Thread
UI manipulation
with native
components
Business logic &
Description of what
components to render
How Native is React Native?
JS Thread Main Thread
UI manipulation
with native
components
Business logic &
Description of what
components to render
Bridge
How much code can we reuse?
Tip: if you develop in one platform,
test the app in the other from time to time
70%? 80%? 90%?
How to start a project
Option 1: create-react-native-app
$ npm install -g create-react-native-app
$ create-react-native-app AwesomeProject
Option 1: create-react-native-app
Only JS, no iOS or Android code
(outside node_modules)
If you want to modify native code, $ npm run eject
Uses the Expo app to test in real device
Meant to have a quick way of trying
react-native
Option 2: react-native init
$ npm install -g react-native-cli
$ react-native init AwesomeProject
Option 2: react-native init
Complete project with native code
More control
Needed to use things like CodePush
Doesn’t need external tools to publish to
the store
Getting our hands dirty
git clone https://github.com/Limenius/workshop-react-native.git
You are supposed to have done this
🙏
And then yarn install
git checkout master
react-native run-ios
And then
Or
react-native run-android
Debug tools Cmd + d
(Cmd + r)
ctrl+m / cmd+m
Play around
Open app/App.js with an editor
<Text style={styles.welcome}>Hi there!</Text>Change the text in
Try nesting
<Text>
<Text style={styles.welcome}>Hi there!</Text>
Amigo
</Text>
Try changing some styles
welcome: {
fontSize: 100,
textAlign: 'center',
margin: 10,
},
Try placing a console.log(‘hi’) before return(… and see it in
Chrome dev tools
https://www.slideshare.net/nachomartin/react-native-workshop-react-alicante
Familiarize with errors
What happens if we…
remove a closing tag (</View>)
<View style={styles.container}>
Hi there!
</View>
put text not wrapped in <Text/>
try to comment a JSX line with //
return (
<View style={styles.container}>
<Text style={styles.welcome}>Hi there!</Text>
</View>
<View/>
)
have two root elements
use wrong properties for styles ( rename flex -> flexo )
remove the words export default
Basic components
git checkout elements
git reset HEAD --hard
(To discard your changes)
Exercise:
Play with the basic components
app/App.js
Exercise: Build new components
Can you build a new component combining others?
Ideas: Image with footer (<Text/>), two buttons that display different alerts
Can you pass props to that component?
Ideas: Pass the text of the footer with props, pass also the image, pass the titles of the buttons
Can your build a component with local state?
Ideas: Modify the counter to have a “minus 1” button
Style 💅
No CSS. Everything is JS
<View style={{
borderLeftColor: Colors.accent,
borderLeftWidth: 9,
backgroundColor: Colors.backgroundSection,
padding: 18,
paddingVertical: 9,
}}>
No class
No dimensions in pixels
No things like padding: 19 9 3 1
camelCased
Use constants
StyleSheet
<View style={Styles.headline}>
const Styles = StyleSheet.create({
headline: {
borderLeftColor: Colors.accent,
borderLeftWidth: 9,
backgroundColor: Colors.backgroundSection,
paddingLeft: 18,
paddingRight: 18,
paddingTop: 9,
paddingBottom: 9,
},
})
Combination
<View style={[Styles.headline, {backgroundColor: 'red'}]}>
const Styles = StyleSheet.create({
headline: {
borderLeftColor: Colors.accent,
borderLeftWidth: 9,
paddingLeft: 18,
paddingRight: 18,
paddingTop: 9,
paddingBottom: 9,
},
})
git checkout styles
(To discard your changes)
git reset HEAD --hard
We want to build this
Our first goal is to get this
(We will practice layouts in the next section)
components/MovieHeader.js
height: 210
fontWeight:‘bold’
fontSize: FontSizes.LargeTitle
48x48, rounded
backgroundColor: Colors.highlight
color: Colors.text
color: Colors.text
fontWeight:‘bold’
border: left, size 9, Colors.accent
padding: 9, 18
backgroundColor: Colors.backgroundSection
Exercise 1
84x84
Colors.text, bold
Container has: border at bottom size 1, Colors.subtleAccent
and background is 'white'
components/ListItemActor.js
Exercise 2
FontSizes.gigantic
Colors.background
Container has: a background with color: Colors.highlight
components/MainHeader.js
Image is 40x90
FontSizes.subhead
With weight ‘200’
Colors.background
Pro exercise:Think how would you add support for themes
Dimensions
import {
Dimensions,
} from 'react-native'
const windowSize = Dimensions.get('window')
mainImage: {
height: windowSize.height /3,
width: undefined
},
components/MovieHeader.js
Dimensions
import {
Dimensions,
} from 'react-native'
const windowSize = Dimensions.get('window')
mainImage: {
height: windowSize.height /3,
width: undefined
},
Our image height depends on the
Height of the window
Use sparingly
components/MovieHeader.js
Dimensions
import {
Dimensions,
} from 'react-native'
const windowSize = Dimensions.get('window')
mainImage: {
height: windowSize.height /3,
width: undefined
},
Our image height depends on the
Height of the window
Use sparingly
Exercise: Can you make another style dependant of
Dimensions?
What will happen if the device is rotated?
Can you find anything in the documentation to fix it?
components/MovieHeader.js
Further reading
https://www.okgrow.com/posts/react-native-styling-tips
https://madebymany.com/stories/a-year-of-react-native-styling-part-1
https://medium.com/robin-powered/introducing-glamorous-for-react-native-1b8365e7f33f
https://github.com/styled-components/styled-components
Explore libraries to do CSS in JS
Layouts
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘column' flexDirection: ‘row’
(Default)
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘column' flexDirection: ‘row’
(Default)
main direction
crossdirection
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘column' flexDirection: ‘row’
(Default)
main direction
crossdirection
cross direction
maindirection
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘column’
(Default)
‘flex-start’ ‘flex-end’ ‘center' ‘space-around’ ‘space-between’
flexDirection: ‘row’
(Default)
‘flex-start’ ‘flex-end’ ‘center' ‘space-around’ ‘space-between’
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘column’
(Default)
‘flex-start’ ‘flex-end’ ‘center' ‘stretch’ ‘baseline’
flexDirection: ‘row’
(Default)
‘flex-start’ ‘flex-end’ ‘center' ‘stretch’ ‘baseline’
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘row’
‘baseline’
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flexDirection: ‘column’
alignSelf: ’end’
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flex: 1
flex: 0
flex: 0
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flex: 5
flex: 2
flex: 3
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flex: 0.5
flex: 0.2
flex: 0.3
This is flexbox realm
flexDirection
justifyContent
alignItems
alignSelf
flex
alignContent
flexBasis
flexGrow
flexShrink
flexWrap
flex: 25
flex: 10
flex: 15
git checkout layout
(To discard your changes)
git reset HEAD --hard
Our goal
app/components/MovieHeader.js
app/components/MovieHeader.js
18
Exercise 1
app/components/ListItemActor.js
Exercise 2
Hint: create subviews if you need them
Optional: can you come up with a different layout for any of our three components?
app/components/MainHeader.js
Further reading
https://facebook.github.io/yoga/docs/getting-started/
Docs:
https://github.com/jondot/ReactNativeKatas
Very good practice:
Lists
Lists are important in mobile
Naive lists, as in the web
export default class Movie extends Component {
constructor(props) {
super(props)
this.state = {
movie: movies.find((movie) => movie.name === 'Pulp Fiction')
}
}
render() {
return (
<View>
<MovieHeader movie={this.state.movie}/>
{ this.state.movie.actors.map(actor => (
<ListItem key={actor} name={actor} image={actors[actor].image}/>
))}
</View>
)
}
}
app/components/Movie.js
Naive lists, as in the web
export default class Movie extends Component {
constructor(props) {
super(props)
this.state = {
movie: movies.find((movie) => movie.name === 'Pulp Fiction')
}
}
render() {
return (
<View>
<MovieHeader movie={this.state.movie}/>
{ this.state.movie.actors.map(actor => (
<ListItem key={actor} name={actor} image={actors[actor].image}/>
))}
</View>
)
}
}
Important to help the reconciler do its work
app/components/Movie.js
Exercise
git checkout lists
Can you build a list of movies in
app/components/MovieList.js ?
(To discard your changes)
git reset HEAD --hard
FlatList
Highly optimized List component
Features:
• Scroll loading (onEndReached).
• Pull to refresh (onRefresh / refreshing).
• Configurable viewability (VPV) callbacks (onViewableItemsChanged / viewabilityConfig).
• Horizontal mode (horizontal).
• Intelligent item and section separators.
• Multi-column support (numColumns)
• scrollToEnd, scrollToIndex, and scrollToItem
• Better Flow typing.
FlatList
render() {
return (
<View>
<MovieHeader movie={this.state.movie}/>
<FlatList
data={this.state.movie.actors}
renderItem={({item}) =>
<ListItem name={item} image={this.state.actors[item].image}/>
}
/>
</View>
)
}
app/components/Movie.js
FlatList
FlatList
What about the keys?
FlatList
What about the keys?
<FlatList
data={this.state.movie.actors}
keyExtractor={item => item}
renderItem={({item}) =>
<ListItem name={item} image={this.state.actors[item].image}/>
}
/>
FlatList
What about the keys?
<FlatList
data={this.state.movie.actors}
keyExtractor={item => item}
renderItem={({item}) =>
<ListItem name={item} image={this.state.actors[item].image}/>
}
/>
FlatList
Scrolleable area
<FlatList
data={this.state.movie.actors}
keyExtractor={item => item}
renderItem={({item}) =>
<ListItem name={item} image={this.state.actors[item].image}/>
}
/>
<MovieHeader movie={this.state.movie}/>
FlatList
Desired scrolleable area
FlatList
Desired scrolleable area
<FlatList
data={this.state.movie.actors}
ListHeaderComponent={<MovieHeader movie={this.state.movie}/>}
keyExtractor={item => item}
renderItem={({item}) =>
<ListItem name={item} image={this.state.actors[item].image}/>
}
/>
FlatList
Desired scrolleable area
<FlatList
data={this.state.movie.actors}
ListHeaderComponent={<MovieHeader movie={this.state.movie}/>}
keyExtractor={item => item}
renderItem={({item}) =>
<ListItem name={item} image={this.state.actors[item].image}/>
}
/>
Exercise
Can you use FlatList in
app/components/MovieList.js ?
git checkout flatLists
item => item
reminder
In this case works as
function(item) {
return item
}
git reset HEAD —hard
(To discard your changes)
Further reading
https://facebook.github.io/react-native/blog/2017/03/13/
better-list-views.html
Read the docs of the components:
FlatList
SectionList
VirtualizedList
Navigation
Navigation
react-navigation
Several options
StackNavigator TabNavigator DrawerNavigator Or combine them
Several options
StackNavigator TabNavigator DrawerNavigator Or combine them
Several options
StackNavigator TabNavigator DrawerNavigator Or combine them
Several options
StackNavigator TabNavigator DrawerNavigator Or combine them
Let’s do it
git checkout navigation
(To discard your changes)
git reset HEAD --hard
Let’s do it
const App = createStackNavigator({
Home: { screen: MovieList },
Movie: { screen: Movie },
}, {
navigationOptions: {
headerTintColor: Colors.accent,
headerStyle: Styles.header,
}
})
app/App.js
Let’s do it
const App = createStackNavigator({
Home: { screen: MovieList },
Movie: { screen: Movie },
}, {
navigationOptions: {
headerTintColor: Colors.accent,
headerStyle: Styles.header,
}
})
app/App.js
export default class MovieList extends Component {
static navigationOptions = {
title: 'Movies',
}
//…
app/components/MovieList.js
Let’s do it
const App = createStackNavigator({
Home: { screen: MovieList },
Movie: { screen: Movie },
}, {
navigationOptions: {
headerTintColor: Colors.accent,
headerStyle: Styles.header,
}
})
app/App.js
export default class MovieList extends Component {
static navigationOptions = {
title: 'Movies',
}
//…
app/components/MovieList.js
<FlatList
data={this.state.movies}
ListHeaderComponent={<MainHeader/>}
keyExtractor={item => item.name}
renderItem={({item}) =>
<TouchableHighlight
underlayColor={Colors.subtleAccent}
activeOpacity={0.5}
onPress={() => navigate('Movie', {name: item.name})}
>
<View>
<ListItem name={item.name} image={item.image}/>
</View>
</TouchableHighlight>
}
/>
In render()
Let’s do it
const App = createStackNavigator({
Home: { screen: MovieList },
Movie: { screen: Movie },
}, {
navigationOptions: {
headerTintColor: Colors.accent,
headerStyle: Styles.header,
}
})
app/App.js
export default class MovieList extends Component {
static navigationOptions = {
title: 'Movies',
}
//…
app/components/MovieList.js
<FlatList
data={this.state.movies}
ListHeaderComponent={<MainHeader/>}
keyExtractor={item => item.name}
renderItem={({item}) =>
<TouchableHighlight
underlayColor={Colors.subtleAccent}
activeOpacity={0.5}
onPress={() => navigate('Movie', {name: item.name})}
>
<View>
<ListItem name={item.name} image={item.image}/>
</View>
</TouchableHighlight>
}
/>
In render()
Exercise
Can you make a navigation transition from Movie to
app/components/Actor ?
Steps:
- Declare the screen in app/App.js
- Use a TouchableHighlight to capture onPress in the actors
list of <Movie/>
- Provide an appropriate title in <Actor/>
- Make the actor displayed based on
props.navigation.state.params.name
Optional: have a look at
https://reactnavigation.org/docs/en/stack-navigator.html
And tweak the navigation (Ideas: mode modal, add something to headerRight)
Networking
Networking
React-native uses the Fetch API
If you already know it, you are all set 🎉 
Let’s do it
componentDidMount() {
return fetch(baseUrl + '/movies')
.then((response) => response.json())
.then((responseJson) => {
this.setState({
isLoading: false,
movies: responseJson,
})
})
.catch((error) => {
console.error(error);
})
}
app/components/MovieList.js
Let’s do it
git checkout networking
yarn start-server
(or npm run start-server)
(To discard your changes)
git reset HEAD --hard
Further reading
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Docs:
https://github.com/mzabriskie/axios
Additional libraries:
Interactive
Our goal
Working with state
Not specific of React Native,
we just use what we know of React 
Let’s do it
git checkout interactive
(To discard your changes)
git reset HEAD --hard
Modify the native side
Cases where it is needed
Installing packages that have a native side
Making our own changes or components
Installing assets, such as fonts
…
Simple case
Install this font
Let’s do it
"rnpm": {
"assets": ["./assets/fonts/"]
}
package.json
git checkout mod-native
(To discard your changes)
git reset HEAD --hard
(Expo users: https://docs.expo.io/versions/latest/guides/using-custom-fonts)
Let’s do it
"rnpm": {
"assets": ["./assets/fonts/"]
}
package.json
react-native link
git checkout mod-native
(To discard your changes)
git reset HEAD --hard
(Expo users: https://docs.expo.io/versions/latest/guides/using-custom-fonts)
Assets linked
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: android/app/src/main/assets/fonts/OleoScript-Bold.ttf
new file: android/app/src/main/assets/fonts/OleoScript-Regular.ttf
modified: ios/travolta.xcodeproj/project.pbxproj
modified: ios/travolta/Info.plist
modified: package.json
Summary:
What is React Native
Starting a project
Working with Styles
Layout
Lists
Navigation
Networking
Touching the native side
Thanks! @nacmartin
nacho@limenius.com

More Related Content

What's hot

React native
React nativeReact native
React native
React nativeReact native
React native
Vikrant Negi
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
Dani Akash
 
React Native
React Native React Native
React Native
vishal kumar
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React Native
FITC
 
S60 3rd FP2 Widgets
S60 3rd FP2 WidgetsS60 3rd FP2 Widgets
S60 3rd FP2 Widgets
romek
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
Knoldus Inc.
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
SheilaJimenezMorejon
 
React Native
React NativeReact Native
React Native
Craig Jolicoeur
 
Roadmap to Development
Roadmap to DevelopmentRoadmap to Development
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
Vishnu Suresh
 
React Native
React NativeReact Native
React Native
ASIMYILDIZ
 
Flutter talkshow
Flutter talkshowFlutter talkshow
Flutter talkshow
Nhan Cao
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
Andreas Jakl
 
Mobile Web Apps
Mobile Web AppsMobile Web Apps
Mobile Web Apps
Athhar Ahamed
 
The magic of flutter
The magic of flutterThe magic of flutter
The magic of flutter
Shady Selim
 
Flutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for businessFlutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for business
Bartosz Kosarzycki
 
Hybrid mobile app
Hybrid mobile appHybrid mobile app
Hybrid mobile app
Palani Kumar
 
Introduction to React Native - Nader Dabit
Introduction to React Native - Nader DabitIntroduction to React Native - Nader Dabit
Introduction to React Native - Nader Dabit
Amazon Web Services
 
Flutter
FlutterFlutter

What's hot (20)

React native
React nativeReact native
React native
 
React native
React nativeReact native
React native
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
 
React Native
React Native React Native
React Native
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React Native
 
S60 3rd FP2 Widgets
S60 3rd FP2 WidgetsS60 3rd FP2 Widgets
S60 3rd FP2 Widgets
 
Hybrid application development
Hybrid application developmentHybrid application development
Hybrid application development
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
React Native
React NativeReact Native
React Native
 
Roadmap to Development
Roadmap to DevelopmentRoadmap to Development
Roadmap to Development
 
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
 
React Native
React NativeReact Native
React Native
 
Flutter talkshow
Flutter talkshowFlutter talkshow
Flutter talkshow
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Mobile Web Apps
Mobile Web AppsMobile Web Apps
Mobile Web Apps
 
The magic of flutter
The magic of flutterThe magic of flutter
The magic of flutter
 
Flutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for businessFlutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for business
 
Hybrid mobile app
Hybrid mobile appHybrid mobile app
Hybrid mobile app
 
Introduction to React Native - Nader Dabit
Introduction to React Native - Nader DabitIntroduction to React Native - Nader Dabit
Introduction to React Native - Nader Dabit
 
Flutter
FlutterFlutter
Flutter
 

Similar to Introduction to React Native Workshop

React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React Alicante
Ignacio Martín
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
Ignacio Martín
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-Native
JSFestUA
 
React js
React jsReact js
React js
Rajesh Kolla
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
React Native: Introduction
React Native: IntroductionReact Native: Introduction
React Native: Introduction
InnerFood
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
Tariqul islam
 
How to implement multiple layouts using React router V4.pptx
How to implement multiple layouts using React router V4.pptxHow to implement multiple layouts using React router V4.pptx
How to implement multiple layouts using React router V4.pptx
BOSC Tech Labs
 
[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view
NAVER D2
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
Sergio Nakamura
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
Lessons from a year of building apps with React Native
Lessons from a year of building apps with React NativeLessons from a year of building apps with React Native
Lessons from a year of building apps with React Native
Ryan Boland
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native Introduction
Visual Engineering
 
Turku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-componentsTurku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-components
James Stone
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
Elyse Kolker Gordon
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 upload
Debnath Sinha
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
joshcjensen
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
Rami Sayar
 
Building user interface with react
Building user interface with reactBuilding user interface with react
Building user interface with react
Amit Thakkar
 

Similar to Introduction to React Native Workshop (20)

React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React Alicante
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
JS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-NativeJS Fest 2018. Илья Иванов. Введение в React-Native
JS Fest 2018. Илья Иванов. Введение в React-Native
 
React js
React jsReact js
React js
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
React Native: Introduction
React Native: IntroductionReact Native: Introduction
React Native: Introduction
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
How to implement multiple layouts using React router V4.pptx
How to implement multiple layouts using React router V4.pptxHow to implement multiple layouts using React router V4.pptx
How to implement multiple layouts using React router V4.pptx
 
[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view[1D6]RE-view of Android L developer PRE-view
[1D6]RE-view of Android L developer PRE-view
 
Introduction to React for Frontend Developers
Introduction to React for Frontend DevelopersIntroduction to React for Frontend Developers
Introduction to React for Frontend Developers
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Lessons from a year of building apps with React Native
Lessons from a year of building apps with React NativeLessons from a year of building apps with React Native
Lessons from a year of building apps with React Native
 
Workshop 24: React Native Introduction
Workshop 24: React Native IntroductionWorkshop 24: React Native Introduction
Workshop 24: React Native Introduction
 
Turku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-componentsTurku loves-storybook-styleguidist-styled-components
Turku loves-storybook-styleguidist-styled-components
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
Js foo - Sept 8 upload
Js foo - Sept 8 uploadJs foo - Sept 8 upload
Js foo - Sept 8 upload
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Building user interface with react
Building user interface with reactBuilding user interface with react
Building user interface with react
 

More from Ignacio Martín

Elixir/OTP for PHP developers
Elixir/OTP for PHP developersElixir/OTP for PHP developers
Elixir/OTP for PHP developers
Ignacio Martín
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - Limenius
Ignacio Martín
 
Server Side Rendering of JavaScript in PHP
Server Side Rendering of JavaScript in PHPServer Side Rendering of JavaScript in PHP
Server Side Rendering of JavaScript in PHP
Ignacio Martín
 
Extending Redux in the Server Side
Extending Redux in the Server SideExtending Redux in the Server Side
Extending Redux in the Server Side
Ignacio Martín
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
Ignacio Martín
 
Asegurando APIs en Symfony con JWT
Asegurando APIs en Symfony con JWTAsegurando APIs en Symfony con JWT
Asegurando APIs en Symfony con JWT
Ignacio Martín
 
Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6
Ignacio Martín
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
Ignacio Martín
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
Ignacio Martín
 
Integrando React.js en aplicaciones Symfony (deSymfony 2016)
Integrando React.js en aplicaciones Symfony (deSymfony 2016)Integrando React.js en aplicaciones Symfony (deSymfony 2016)
Integrando React.js en aplicaciones Symfony (deSymfony 2016)
Ignacio Martín
 
Adding Realtime to your Projects
Adding Realtime to your ProjectsAdding Realtime to your Projects
Adding Realtime to your Projects
Ignacio Martín
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsIgnacio Martín
 
Symfony 2 CMF
Symfony 2 CMFSymfony 2 CMF
Symfony 2 CMF
Ignacio Martín
 
Doctrine2 sf2Vigo
Doctrine2 sf2VigoDoctrine2 sf2Vigo
Doctrine2 sf2Vigo
Ignacio Martín
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
Ignacio Martín
 

More from Ignacio Martín (16)

Elixir/OTP for PHP developers
Elixir/OTP for PHP developersElixir/OTP for PHP developers
Elixir/OTP for PHP developers
 
Symfony 4 Workshop - Limenius
Symfony 4 Workshop - LimeniusSymfony 4 Workshop - Limenius
Symfony 4 Workshop - Limenius
 
Server Side Rendering of JavaScript in PHP
Server Side Rendering of JavaScript in PHPServer Side Rendering of JavaScript in PHP
Server Side Rendering of JavaScript in PHP
 
Extending Redux in the Server Side
Extending Redux in the Server SideExtending Redux in the Server Side
Extending Redux in the Server Side
 
Redux Sagas - React Alicante
Redux Sagas - React AlicanteRedux Sagas - React Alicante
Redux Sagas - React Alicante
 
Asegurando APIs en Symfony con JWT
Asegurando APIs en Symfony con JWTAsegurando APIs en Symfony con JWT
Asegurando APIs en Symfony con JWT
 
Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6Redux saga: managing your side effects. Also: generators in es6
Redux saga: managing your side effects. Also: generators in es6
 
Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
 
Integrando React.js en aplicaciones Symfony (deSymfony 2016)
Integrando React.js en aplicaciones Symfony (deSymfony 2016)Integrando React.js en aplicaciones Symfony (deSymfony 2016)
Integrando React.js en aplicaciones Symfony (deSymfony 2016)
 
Adding Realtime to your Projects
Adding Realtime to your ProjectsAdding Realtime to your Projects
Adding Realtime to your Projects
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worlds
 
Symfony 2 CMF
Symfony 2 CMFSymfony 2 CMF
Symfony 2 CMF
 
Doctrine2 sf2Vigo
Doctrine2 sf2VigoDoctrine2 sf2Vigo
Doctrine2 sf2Vigo
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 

Introduction to React Native Workshop

  • 2. Nacho Martin I write code at Limenius. We build tailor-made projects, and provide consultancy and formation. We are very happy with React and React Native.
  • 3. https://github.com/Limenius/workshop-react-native.git Before we start 🙏 Please go to where you have cloned the repo of the project And run git fetch
  • 4. Goal of the workshop To be able to estimate how long would it take you to create a first React Native project (and if you would enjoy it)
  • 5. Roadmap: What is React Native Starting a project Working with Styles Layout Lists Navigation Networking Touching the native side
  • 6. What is React Native?
  • 7. Fundamental premise of React Give me a state and a render() method that depends on it and forget about how and when to render.
  • 8. render() { return ( <div className="App"> <button onClick={this.tick}>Click me!</button> <span>Clicks: {this.state.count}</span> </div> ) }
  • 9. render() { return ( <div className="App"> <button onClick={this.tick}>Click me!</button> <span>Clicks: {this.state.count}</span> </div> ) } render() { return ( <View style={…}> <Button onPress={this.tick}>Click me!</Button> <Text>Clicks: {this.state.count}</Text> </View> ) }
  • 10. render() { return ( <div className="App"> <button onClick={this.tick}>Click me!</button> <span>Clicks: {this.state.count}</span> </div> ) } render() { return ( <View style={…}> <Button onPress={this.tick}>Click me!</Button> <Text>Clicks: {this.state.count}</Text> </View> ) }
  • 11. render() { return ( <div className="App"> <button onClick={this.tick}>Click me!</button> <span>Clicks: {this.state.count}</span> </div> ) } render() { return ( <View style={…}> <Button onPress={this.tick}>Click me!</Button> <Text>Clicks: {this.state.count}</Text> </View> ) } React Native
  • 12. How is this possible Reconciliation Determines what parts of the tree have changed
  • 13. How is this possible Reconciliation Determines what parts of the tree have changed Rendering Actually updates the app
  • 14. How is this possible Reconciliation Determines what parts of the tree have changed Rendering Actually updates the app We can have several renderers
  • 17. React targets Main react-dom react-native Web iOS android But also react-art  react-canvas react-three ReactLibertyreact-worker-dom
  • 18. React targets Main react-dom react-native Web iOS android But also react-art  react-canvas react-three ReactLibertyreact-worker-dom react-konsul raxreact-native  react-blessedreact-tvml
  • 19. React targets Main react-dom react-native Web iOS android But also react-art  react-canvas react-three ReactLibertyreact-worker-dom react-konsul raxreact-native  react-blessedreact-tvml React-GLreact-vr  react-hardware react-fs-renderer react-x11
  • 20. React targets Main react-dom react-native Web iOS android But also react-art  react-canvas react-three ReactLibertyreact-worker-dom react-konsul raxreact-native  react-blessedreact-tvml React-GLreact-vr  react-hardware react-fs-renderer react-x11 redocx react-titanium  React-Gibbon react-pdf  react-test-renderer
  • 21. React targets Main react-dom react-native Web iOS android But also react-art  react-canvas react-three ReactLibertyreact-worker-dom react-konsul raxreact-native  react-blessedreact-tvml React-GLreact-vr  react-hardware react-fs-renderer react-x11 redocx react-titanium  React-Gibbon react-pdf  react-test-renderer ink  react-sketchapp 
  • 22. React targets Main react-dom react-native Web iOS android But also react-art  react-canvas react-three ReactLibertyreact-worker-dom react-konsul raxreact-native  react-blessedreact-tvml React-GLreact-vr  react-hardware react-fs-renderer react-x11 redocx react-titanium  React-Gibbon react-pdf  react-test-renderer ink  react-sketchapp  And more
  • 27. How Native is React Native? JS Thread Business logic & Description of what components to render
  • 28. How Native is React Native? JS Thread Main Thread UI manipulation with native components Business logic & Description of what components to render
  • 29. How Native is React Native? JS Thread Main Thread UI manipulation with native components Business logic & Description of what components to render Bridge
  • 30. How much code can we reuse? Tip: if you develop in one platform, test the app in the other from time to time 70%? 80%? 90%?
  • 31. How to start a project
  • 32. Option 1: create-react-native-app $ npm install -g create-react-native-app $ create-react-native-app AwesomeProject
  • 33. Option 1: create-react-native-app Only JS, no iOS or Android code (outside node_modules) If you want to modify native code, $ npm run eject Uses the Expo app to test in real device Meant to have a quick way of trying react-native
  • 34. Option 2: react-native init $ npm install -g react-native-cli $ react-native init AwesomeProject
  • 35. Option 2: react-native init Complete project with native code More control Needed to use things like CodePush Doesn’t need external tools to publish to the store
  • 37. git clone https://github.com/Limenius/workshop-react-native.git You are supposed to have done this 🙏 And then yarn install
  • 38. git checkout master react-native run-ios And then Or react-native run-android
  • 39. Debug tools Cmd + d (Cmd + r) ctrl+m / cmd+m
  • 40. Play around Open app/App.js with an editor <Text style={styles.welcome}>Hi there!</Text>Change the text in Try nesting <Text> <Text style={styles.welcome}>Hi there!</Text> Amigo </Text> Try changing some styles welcome: { fontSize: 100, textAlign: 'center', margin: 10, }, Try placing a console.log(‘hi’) before return(… and see it in Chrome dev tools https://www.slideshare.net/nachomartin/react-native-workshop-react-alicante
  • 41. Familiarize with errors What happens if we… remove a closing tag (</View>) <View style={styles.container}> Hi there! </View> put text not wrapped in <Text/> try to comment a JSX line with // return ( <View style={styles.container}> <Text style={styles.welcome}>Hi there!</Text> </View> <View/> ) have two root elements use wrong properties for styles ( rename flex -> flexo ) remove the words export default
  • 43. git checkout elements git reset HEAD --hard (To discard your changes)
  • 44. Exercise: Play with the basic components app/App.js
  • 45. Exercise: Build new components Can you build a new component combining others? Ideas: Image with footer (<Text/>), two buttons that display different alerts Can you pass props to that component? Ideas: Pass the text of the footer with props, pass also the image, pass the titles of the buttons Can your build a component with local state? Ideas: Modify the counter to have a “minus 1” button
  • 47. No CSS. Everything is JS <View style={{ borderLeftColor: Colors.accent, borderLeftWidth: 9, backgroundColor: Colors.backgroundSection, padding: 18, paddingVertical: 9, }}> No class No dimensions in pixels No things like padding: 19 9 3 1 camelCased Use constants
  • 48. StyleSheet <View style={Styles.headline}> const Styles = StyleSheet.create({ headline: { borderLeftColor: Colors.accent, borderLeftWidth: 9, backgroundColor: Colors.backgroundSection, paddingLeft: 18, paddingRight: 18, paddingTop: 9, paddingBottom: 9, }, })
  • 49. Combination <View style={[Styles.headline, {backgroundColor: 'red'}]}> const Styles = StyleSheet.create({ headline: { borderLeftColor: Colors.accent, borderLeftWidth: 9, paddingLeft: 18, paddingRight: 18, paddingTop: 9, paddingBottom: 9, }, })
  • 50. git checkout styles (To discard your changes) git reset HEAD --hard
  • 51. We want to build this
  • 52. Our first goal is to get this (We will practice layouts in the next section)
  • 53. components/MovieHeader.js height: 210 fontWeight:‘bold’ fontSize: FontSizes.LargeTitle 48x48, rounded backgroundColor: Colors.highlight color: Colors.text color: Colors.text fontWeight:‘bold’ border: left, size 9, Colors.accent padding: 9, 18 backgroundColor: Colors.backgroundSection
  • 54. Exercise 1 84x84 Colors.text, bold Container has: border at bottom size 1, Colors.subtleAccent and background is 'white' components/ListItemActor.js
  • 55. Exercise 2 FontSizes.gigantic Colors.background Container has: a background with color: Colors.highlight components/MainHeader.js Image is 40x90 FontSizes.subhead With weight ‘200’ Colors.background Pro exercise:Think how would you add support for themes
  • 56. Dimensions import { Dimensions, } from 'react-native' const windowSize = Dimensions.get('window') mainImage: { height: windowSize.height /3, width: undefined }, components/MovieHeader.js
  • 57. Dimensions import { Dimensions, } from 'react-native' const windowSize = Dimensions.get('window') mainImage: { height: windowSize.height /3, width: undefined }, Our image height depends on the Height of the window Use sparingly components/MovieHeader.js
  • 58. Dimensions import { Dimensions, } from 'react-native' const windowSize = Dimensions.get('window') mainImage: { height: windowSize.height /3, width: undefined }, Our image height depends on the Height of the window Use sparingly Exercise: Can you make another style dependant of Dimensions? What will happen if the device is rotated? Can you find anything in the documentation to fix it? components/MovieHeader.js
  • 61. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap
  • 62. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘column' flexDirection: ‘row’ (Default)
  • 63. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘column' flexDirection: ‘row’ (Default) main direction crossdirection
  • 64. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘column' flexDirection: ‘row’ (Default) main direction crossdirection cross direction maindirection
  • 65. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘column’ (Default) ‘flex-start’ ‘flex-end’ ‘center' ‘space-around’ ‘space-between’ flexDirection: ‘row’ (Default) ‘flex-start’ ‘flex-end’ ‘center' ‘space-around’ ‘space-between’
  • 66. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘column’ (Default) ‘flex-start’ ‘flex-end’ ‘center' ‘stretch’ ‘baseline’ flexDirection: ‘row’ (Default) ‘flex-start’ ‘flex-end’ ‘center' ‘stretch’ ‘baseline’
  • 67. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘row’ ‘baseline’
  • 68. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flexDirection: ‘column’ alignSelf: ’end’
  • 69. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flex: 1 flex: 0 flex: 0
  • 70. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flex: 5 flex: 2 flex: 3
  • 71. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flex: 0.5 flex: 0.2 flex: 0.3
  • 72. This is flexbox realm flexDirection justifyContent alignItems alignSelf flex alignContent flexBasis flexGrow flexShrink flexWrap flex: 25 flex: 10 flex: 15
  • 73. git checkout layout (To discard your changes) git reset HEAD --hard
  • 78. Exercise 2 Hint: create subviews if you need them Optional: can you come up with a different layout for any of our three components? app/components/MainHeader.js
  • 80. Lists
  • 81. Lists are important in mobile
  • 82. Naive lists, as in the web export default class Movie extends Component { constructor(props) { super(props) this.state = { movie: movies.find((movie) => movie.name === 'Pulp Fiction') } } render() { return ( <View> <MovieHeader movie={this.state.movie}/> { this.state.movie.actors.map(actor => ( <ListItem key={actor} name={actor} image={actors[actor].image}/> ))} </View> ) } } app/components/Movie.js
  • 83. Naive lists, as in the web export default class Movie extends Component { constructor(props) { super(props) this.state = { movie: movies.find((movie) => movie.name === 'Pulp Fiction') } } render() { return ( <View> <MovieHeader movie={this.state.movie}/> { this.state.movie.actors.map(actor => ( <ListItem key={actor} name={actor} image={actors[actor].image}/> ))} </View> ) } } Important to help the reconciler do its work app/components/Movie.js
  • 84. Exercise git checkout lists Can you build a list of movies in app/components/MovieList.js ? (To discard your changes) git reset HEAD --hard
  • 85. FlatList Highly optimized List component Features: • Scroll loading (onEndReached). • Pull to refresh (onRefresh / refreshing). • Configurable viewability (VPV) callbacks (onViewableItemsChanged / viewabilityConfig). • Horizontal mode (horizontal). • Intelligent item and section separators. • Multi-column support (numColumns) • scrollToEnd, scrollToIndex, and scrollToItem • Better Flow typing.
  • 86. FlatList render() { return ( <View> <MovieHeader movie={this.state.movie}/> <FlatList data={this.state.movie.actors} renderItem={({item}) => <ListItem name={item} image={this.state.actors[item].image}/> } /> </View> ) } app/components/Movie.js
  • 89. FlatList What about the keys? <FlatList data={this.state.movie.actors} keyExtractor={item => item} renderItem={({item}) => <ListItem name={item} image={this.state.actors[item].image}/> } />
  • 90. FlatList What about the keys? <FlatList data={this.state.movie.actors} keyExtractor={item => item} renderItem={({item}) => <ListItem name={item} image={this.state.actors[item].image}/> } />
  • 91. FlatList Scrolleable area <FlatList data={this.state.movie.actors} keyExtractor={item => item} renderItem={({item}) => <ListItem name={item} image={this.state.actors[item].image}/> } /> <MovieHeader movie={this.state.movie}/>
  • 93. FlatList Desired scrolleable area <FlatList data={this.state.movie.actors} ListHeaderComponent={<MovieHeader movie={this.state.movie}/>} keyExtractor={item => item} renderItem={({item}) => <ListItem name={item} image={this.state.actors[item].image}/> } />
  • 94. FlatList Desired scrolleable area <FlatList data={this.state.movie.actors} ListHeaderComponent={<MovieHeader movie={this.state.movie}/>} keyExtractor={item => item} renderItem={({item}) => <ListItem name={item} image={this.state.actors[item].image}/> } />
  • 95. Exercise Can you use FlatList in app/components/MovieList.js ? git checkout flatLists item => item reminder In this case works as function(item) { return item } git reset HEAD —hard (To discard your changes)
  • 100. Several options StackNavigator TabNavigator DrawerNavigator Or combine them
  • 101. Several options StackNavigator TabNavigator DrawerNavigator Or combine them
  • 102. Several options StackNavigator TabNavigator DrawerNavigator Or combine them
  • 103. Several options StackNavigator TabNavigator DrawerNavigator Or combine them
  • 104. Let’s do it git checkout navigation (To discard your changes) git reset HEAD --hard
  • 105. Let’s do it const App = createStackNavigator({ Home: { screen: MovieList }, Movie: { screen: Movie }, }, { navigationOptions: { headerTintColor: Colors.accent, headerStyle: Styles.header, } }) app/App.js
  • 106. Let’s do it const App = createStackNavigator({ Home: { screen: MovieList }, Movie: { screen: Movie }, }, { navigationOptions: { headerTintColor: Colors.accent, headerStyle: Styles.header, } }) app/App.js export default class MovieList extends Component { static navigationOptions = { title: 'Movies', } //… app/components/MovieList.js
  • 107. Let’s do it const App = createStackNavigator({ Home: { screen: MovieList }, Movie: { screen: Movie }, }, { navigationOptions: { headerTintColor: Colors.accent, headerStyle: Styles.header, } }) app/App.js export default class MovieList extends Component { static navigationOptions = { title: 'Movies', } //… app/components/MovieList.js <FlatList data={this.state.movies} ListHeaderComponent={<MainHeader/>} keyExtractor={item => item.name} renderItem={({item}) => <TouchableHighlight underlayColor={Colors.subtleAccent} activeOpacity={0.5} onPress={() => navigate('Movie', {name: item.name})} > <View> <ListItem name={item.name} image={item.image}/> </View> </TouchableHighlight> } /> In render()
  • 108. Let’s do it const App = createStackNavigator({ Home: { screen: MovieList }, Movie: { screen: Movie }, }, { navigationOptions: { headerTintColor: Colors.accent, headerStyle: Styles.header, } }) app/App.js export default class MovieList extends Component { static navigationOptions = { title: 'Movies', } //… app/components/MovieList.js <FlatList data={this.state.movies} ListHeaderComponent={<MainHeader/>} keyExtractor={item => item.name} renderItem={({item}) => <TouchableHighlight underlayColor={Colors.subtleAccent} activeOpacity={0.5} onPress={() => navigate('Movie', {name: item.name})} > <View> <ListItem name={item.name} image={item.image}/> </View> </TouchableHighlight> } /> In render()
  • 109. Exercise Can you make a navigation transition from Movie to app/components/Actor ? Steps: - Declare the screen in app/App.js - Use a TouchableHighlight to capture onPress in the actors list of <Movie/> - Provide an appropriate title in <Actor/> - Make the actor displayed based on props.navigation.state.params.name Optional: have a look at https://reactnavigation.org/docs/en/stack-navigator.html And tweak the navigation (Ideas: mode modal, add something to headerRight)
  • 111. Networking React-native uses the Fetch API If you already know it, you are all set 🎉 
  • 112. Let’s do it componentDidMount() { return fetch(baseUrl + '/movies') .then((response) => response.json()) .then((responseJson) => { this.setState({ isLoading: false, movies: responseJson, }) }) .catch((error) => { console.error(error); }) } app/components/MovieList.js
  • 113. Let’s do it git checkout networking yarn start-server (or npm run start-server) (To discard your changes) git reset HEAD --hard
  • 117. Working with state Not specific of React Native, we just use what we know of React 
  • 118. Let’s do it git checkout interactive (To discard your changes) git reset HEAD --hard
  • 120. Cases where it is needed Installing packages that have a native side Making our own changes or components Installing assets, such as fonts …
  • 122. Let’s do it "rnpm": { "assets": ["./assets/fonts/"] } package.json git checkout mod-native (To discard your changes) git reset HEAD --hard (Expo users: https://docs.expo.io/versions/latest/guides/using-custom-fonts)
  • 123. Let’s do it "rnpm": { "assets": ["./assets/fonts/"] } package.json react-native link git checkout mod-native (To discard your changes) git reset HEAD --hard (Expo users: https://docs.expo.io/versions/latest/guides/using-custom-fonts)
  • 124. Assets linked Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: android/app/src/main/assets/fonts/OleoScript-Bold.ttf new file: android/app/src/main/assets/fonts/OleoScript-Regular.ttf modified: ios/travolta.xcodeproj/project.pbxproj modified: ios/travolta/Info.plist modified: package.json
  • 125. Summary: What is React Native Starting a project Working with Styles Layout Lists Navigation Networking Touching the native side