Add (manual) tests to be able to verify working of network and logs
Summary: Added some UI so that we can manually verify that logging and network inspection is working in RN + Flipper. Reviewed By: jknoxville Differential Revision: D20668428 fbshipit-source-id: 4271595583e055b2b0324b3da7ac216c39717093
This commit is contained in:
committed by
Facebook GitHub Bot
parent
64bfc91ea6
commit
60ec958f6b
29
react-native/ReactNativeFlipperExample/App.js
vendored
29
react-native/ReactNativeFlipperExample/App.js
vendored
@@ -8,7 +8,7 @@
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, {useState} from 'react';
|
||||
|
||||
import {
|
||||
SafeAreaView,
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
View,
|
||||
Text,
|
||||
StatusBar,
|
||||
Button,
|
||||
} from 'react-native';
|
||||
|
||||
import {
|
||||
@@ -29,7 +30,10 @@ import {
|
||||
|
||||
import FlipperTicTacToe from './FlipperTicTacToe';
|
||||
|
||||
const API = 'https://status.npmjs.org/';
|
||||
|
||||
const App: () => React$Node = () => {
|
||||
const [npmStatus, setNpmStatus] = useState('NPM status: unknown');
|
||||
return (
|
||||
<>
|
||||
<StatusBar barStyle="dark-content" />
|
||||
@@ -47,6 +51,29 @@ const App: () => React$Node = () => {
|
||||
<View style={styles.sectionContainer}>
|
||||
<FlipperTicTacToe />
|
||||
</View>
|
||||
<View style={styles.sectionContainer}>
|
||||
<Text style={styles.sectionTitle}>Network & Logging</Text>
|
||||
<Text style={styles.sectionDescription}>{npmStatus}</Text>
|
||||
<Button
|
||||
title="Is NPM up?"
|
||||
onPress={() => {
|
||||
console.log('Making request to ' + API);
|
||||
fetch(API, {headers: {accept: 'application/json'}})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
console.log(
|
||||
'Got status: ' + JSON.stringify(data, null, 2),
|
||||
);
|
||||
setNpmStatus(data.status.description);
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Failed to fetch status: ' + e);
|
||||
console.error(e);
|
||||
setNpmStatus('Error: ' + e);
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.sectionContainer}>
|
||||
<Text style={styles.sectionTitle}>Step One</Text>
|
||||
<Text style={styles.sectionDescription}>
|
||||
|
||||
Reference in New Issue
Block a user