React Native Latest Installation
$npx @react-native-community/cli@latest init MyProject --version latest$npx react-native start
$npx react-native run-android
$npx react-native run-iosRun with Device
$adb devices
$npx react-native run-android --deviceId=3612f890$npx react-native log-android
$npx react-native log-ios$npx react-native run-android --mode release
$npx react-native run-ios --mode releaseUse the Latest Installation
$npx @react-native-community/cli@latest init MyProject --version latestCopy the .tsx or .jsx file to the new Project Folder
$cp MyProject_old/App.tsx MyProject/App.tsxIOS Config
MyProject/ios/MyProject/info.plist
Android Config
MyProject/android/app/build.gradle
MyProject/android/app/src/main/AndroidManifest.xml
Rename Icons in MyProject/android/app/src/main/AndroidManifest.xml
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
React Native Platform
import { Platform, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
paddingTop: Platform.OS === 'ios' ? 20 : 0,
},
});import { Platform, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
button: {
backgroundColor: Platform.select({
ios: 'blue',
android: 'green',
}),
},
});import { Platform, StyleSheet } from 'react-native';
var styles = StyleSheet.create({
container: {
flex: 1,
...Platform.select({
ios: {
backgroundColor: 'red',
},
android: {
backgroundColor: 'blue',
},
}),
},
});var Component = Platform.select({
ios: () => require('ComponentIOS'),
android: () => require('ComponentAndroid'),
})();
<Component />import MyComponent from 'components/MyComponent';
//components/MyComponent.ios.js
//components/MyComponent.android.jsimport {widthPercentageToDP as wp, heightPercentageToDP as hp} from 'react-native-responsive-screen';
class Login extends Component {
render() {
return (
<View style={styles.container}>
<View style={styles.textWrapper}>
<Text style={styles.myText}>Login</Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: { flex: 1 },
textWrapper: {
height: hp('70%'), // 70% of height device screen
width: wp('80%') // 80% of width device screen
},
myText: {
fontSize: hp('5%') // End result looks like the provided UI mockup
}
});
export default Login;