Leandro Nunes
a.k.a. "Little Big Nunes". I'm a web development enthusiast who believes Little things make a Big difference!
import React, { Component } from 'react'
import { AppRegistry, View, Text, StyleSheet } from 'react-native'
class HelloWorldApp extends Component {
render() {
return (
<View style={styles.container}>
<Text>Hello World</Text>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
})
AppRegistry.registerComponent('App', () => HelloWorldApp)
<div> | <View> |
---|---|
<span> / <p> | <Text> |
<input type="text"> | <InputText> |
<a> / <button> | <Button> |
<img> | <Image> |
render() {
return (
<View>
<Text>Hello World</Text>
</View>
)
}
render() {
return (
<View style={styles.container}>
<Text style={{color: 'black'}}>Hello World</Text>
</View>
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
})
// 1. Platform
Install Xcode // Android SDK
brew install node
brew install watchman
// 2. React Native CLI
npm install -g react-native-cli
// 3. Creating and Running
react-native init AwesomeProject
cd AwesomeProject
react-native run-ios // run-android
import { Platform, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
height: (Platform.OS === 'ios') ? 200 : 100,
});
// ...
const styles = StyleSheet.create({
container: {
flex: 1,
...Platform.select({
ios: { backgroundColor: 'red' },
android: { backgroundColor: 'blue' },
}),
},
});
By Platform module
// |- BigButton.ios.js
// |- BigButton.android.js
const BigButton = require('./BigButton');
// React Native will automatically pick up
// the right file based on the running platform.
By file extention
By Leandro Nunes
Introduction to React-Native
a.k.a. "Little Big Nunes". I'm a web development enthusiast who believes Little things make a Big difference!