Mobile development challenges
Why React Native?
Architecture
Getting Started
Standard Components
Styles
Slow development and deployment cycle
Platform specific skillset
Stateful, mutable UI
Poor performance of html-based frameworks
Instant reload
Updates without resubmission
Consistent tooling and common APIs for web and mobile
Shared skillset
Code reuse
Backed by native components
Immutable views
External modules and components
Browser debugging
JavaScript Framework
Reuse JS and React experience
Wrapper to standard native IOS or Android Components/APIS
All operations are asynchronuous
Powerful gestures support including mutlitouch
Mac + Xcode
npm install -g react-native-cli
react-native init HelloWorldProject
import React, {
AppRegistry, Component, Text, View,
} from 'react-native';
class Hello extends Component {
render() {
return (
<View><Text>Hello, World!</Text></View>
)
}
}
AppRegistry.registerComponent('Hello', () => Hello);
View
Text
TextInput
TouchableHighlight
Image
ListView
ScrollView
TabBarIOS
var styles = StyleSheet.create({
container: {
borderRadius: 4,
borderWidth: 0.5,
borderColor: '#d6d7da',
},
title: {
fontSize: 19,
fontWeight: 'bold',
},
activeTitle: {
color: 'red',
},
});
<View style={styles.container}>
<Text style={[styles.title, this.props.isActive && styles.activeTitle]} />
</View>
Camel case
Quote text values
Use numbers for dimensions (React adds 'px')
Commans instead of semicolons
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
const reducer = combineReducers(reducers);
const store = createStoreWithMiddleware(reducer);
export default class App extends Component {
render() {
return (
<Provider store={store}>
<CounterApp />
</Provider>
);
}
}
export default connect(state => ({
state: state.counter
}),
(dispatch) => ({
actions: bindActionCreators(counterActions, dispatch)
})
)(CounterApp);