for your next mobile project.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
class App extends Component {
render() {
return (
Hello App!); } } ReactDOM.render(
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
class App extends Component {
constructor () {
super();
this.state = {
count: 0
};
this.add = this.add.bind(this);
}
add () {
this.setState({
count: this.state.count + 1
});
}
render () {
return (
Count = {this.state.count}
);
}
}
ReactDOM.render( , document.getElementById('root'));
import React, { Component } from 'react';
import { AppRegistry, View, Text } from 'react-native';
class App extends Component {
render() {
return (
Hello App!
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => App);
import React, { Component } from 'react';
import {
AppRegistry,
View,
Text,
TouchableOpacity
} from 'react-native';
class App extends Component {
constructor () {
super();
this.state = {
count: 0
};
this.add = this.add.bind(this);
}
add () {
this.setState({
count: this.state.count + 1
});
}
render() {
return (
Count: {this.state.count}
Add One
);
}
}
AppRegistry.registerComponent('AwesomeProject', () => App);
display: 'flex'
flex-direction: 'column'
*Alternative to #1*
$ npm i -g create-react-native-app
$ create-react-native-app my-app
$ cd my-app
$ npm start
$ react-native init appName
$ react-native run-ios
$ react-native run-android
const instructions = Platform.select({
ios: 'You are using iOS',
android: 'You are using Android'
});
if (Platform.os === 'ios') {
// do something
} else if (Platform.os === 'android') {
// do something
}
npm install --save-dev react-devtools
// add “devtools”: “react-devtools” to npm scripts
npm run devtools
console.log(...);
console.warn(...);
console.error(...);
debugger;
import React, { Component } from 'react';
import { NativeModules } from 'react-native';
npm install react-native-camera
react-native link
Embed Web Views!
import React, { Component } from 'react';
import { WebView } from 'react-native';
class MyWeb extends Component {
render() {
return (
);
}
}