rn-button.js
// http://dabbott.github.io/react-native-web-player/
import React, { Component, } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
} from 'react-native';
class MyButton extends Component {
constructor() {
super();
this.state = {
msg: "Before Click",
};
}
_onPressButton() {
console.log("You tapped the button!");
this.setState({ msg: "Buzzer!!"})
fetch('https://api.netpie.io/topic/HelloCMMC/gearname/thing2?auth=PK7fUciCu1ocVPE:r2LOK4ambsj5H2eEEkBZ3vhyc', {
method: 'PUT',
body: 'ON'
}).then((response) => { return response.text() })
.then((msg) => { this.setState({msg: msg }); })
.catch((error) => {
alert("error: " + error);
});;
}
render() {
return (
<View style={{flex: 1, flexDirection: 'column', justifyContent: 'center', alignItems: 'center'}}>
<Text style={{ backgroundColor: ''}}>{this.state.msg}</Text>
<TouchableHighlight onPress={this._onPressButton.bind(this)}>
<Text style={{ backgroundColor: 'powderblue'}}>Click Me</Text>
</TouchableHighlight>
</View>
);
}
}
AppRegistry.registerComponent('SampleApp', () => MyButton);
// http://dabbott.github.io/react-native-web-player/
import React, { Component, } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
} from 'react-native';
class MyButton extends Component {
constructor() {
super();
this.state = {
msg: "Before Click",
};
}
_onPressButton() {
console.log("You tapped the button!");
this.setState({msg: Math.random() });
}
render() {
return (
<View style={{flex: 1, flexDirection: 'column', justifyContent: 'center', alignItems: 'center'}}>
<Text style={{ backgroundColor: ''}}>{this.state.msg}</Text>
<TouchableHighlight onPress={this._onPressButton.bind(this)}>
<Text style={{ backgroundColor: 'powderblue'}}>Click Me</Text>
</TouchableHighlight>
</View>
);
}
}
AppRegistry.registerComponent('SampleApp', () => MyButton);
// http://dabbott.github.io/react-native-web-player/
import React, { Component, } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
} from 'react-native';
class MyButton extends Component {
constructor() {
super();
this.state = {
msg: "Before Click",
};
}
_onPressButton() {
console.log("You tapped the button!");
this.setState({msg: Math.random() });
}
render() {
return (
<View style={{flex: 1, flexDirection: 'column', justifyContent: 'center'}}>
<Text style={{ backgroundColor: 'powderblue'}}>{this.state.msg}</Text>
<TouchableHighlight onPress={this._onPressButton.bind(this)}>
<Text>Click Me</Text>
</TouchableHighlight>
</View>
);
}
}
AppRegistry.registerComponent('SampleApp', () => MyButton);
// http://dabbott.github.io/react-native-web-player/
import React, { Component, } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
} from 'react-native';
class MyButton extends Component {
constructor() {
super();
this.state = {
msg: "Before Click",
};
}
_onPressButton() {
console.log("You tapped the button!");
this.setState({msg: Math.random() });
}
render() {
return (
<View>
<Text>{this.state.msg}</Text>
<TouchableHighlight onPress={this._onPressButton.bind(this)}>
<Text>Click Me</Text>
</TouchableHighlight>
</View>
);
}
}
AppRegistry.registerComponent('SampleApp', () => MyButton);