-
Notifications
You must be signed in to change notification settings - Fork 23
/
rn.js
45 lines (38 loc) · 1.04 KB
/
rn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import './global';
import cryptoExample from './crypto_example';
import bitcoinExample from './bitcoin_example';
import httpExample from './http_example';
export default class ReactNativeExamples extends Component {
state = {
crypto: null,
bitcoin: null,
http: null,
};
componentDidMount() {
process.nextTick(() => {
cryptoExample().then((crypto) => this.setState({crypto}));
bitcoinExample().then((bitcoin) => this.setState({bitcoin}));
httpExample().then((http) => this.setState({http}));
});
}
_renderResult(result) {
if (result === null) {
return 'waiting...';
}
if (result) {
return 'success!';
}
return 'failed.';
}
render() {
return (
<View>
<Text>Crypto: {this._renderResult(this.state.crypto)}</Text>
<Text>Bitcoin: {this._renderResult(this.state.bitcoin)}</Text>
<Text>HTTP: {this._renderResult(this.state.http)}</Text>
</View>
);
}
}