0
Good afternoon!
I have a beginner’s question and unfortunately I am not able to find a language tutorial (who has a link please put in the answers), I just want to show the contents of variables 'ping' and 'connectado' however I am not able to do this.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button} from 'react-native';
import NetInfo from '@react-native-community/netinfo';
import Ping from 'react-native-ping';
var ping, connectado;
export default class App extends Component {
render() {
NetInfo.isConnected.fetch().then(isConnected => {
console.log("Is connected", isConnected);
connectado = isConnected;
});
(async () => {
try {
ms = await Ping.start('www.google.com',{ timeout: 1000 });
console.log(ms);
ping = ms;
} catch (error) {
console.log('special code',error.code, error.message);
}
})();
return (
<View style={styles.container}>
<Text style={styles.welcome}>MS: {ping}</Text>
<Text style={styles.welcome}>Connectado: {connectado}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});