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
@@ -28,6 +28,7 @@ Beyond the React Native specific Flipper plugins described above, with Flipper y
|
|||||||
|
|
||||||
* Device logs
|
* Device logs
|
||||||
* Device crash reporter
|
* Device crash reporter
|
||||||
|
* Inspecting network requests
|
||||||
* Inspecting app local databases
|
* Inspecting app local databases
|
||||||
* Inspecting device preferences
|
* Inspecting device preferences
|
||||||
* Inspecting cached images
|
* Inspecting cached images
|
||||||
|
|||||||
29
react-native/ReactNativeFlipperExample/App.js
vendored
29
react-native/ReactNativeFlipperExample/App.js
vendored
@@ -8,7 +8,7 @@
|
|||||||
* @flow strict-local
|
* @flow strict-local
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React, {useState} from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SafeAreaView,
|
SafeAreaView,
|
||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
View,
|
View,
|
||||||
Text,
|
Text,
|
||||||
StatusBar,
|
StatusBar,
|
||||||
|
Button,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -29,7 +30,10 @@ import {
|
|||||||
|
|
||||||
import FlipperTicTacToe from './FlipperTicTacToe';
|
import FlipperTicTacToe from './FlipperTicTacToe';
|
||||||
|
|
||||||
|
const API = 'https://status.npmjs.org/';
|
||||||
|
|
||||||
const App: () => React$Node = () => {
|
const App: () => React$Node = () => {
|
||||||
|
const [npmStatus, setNpmStatus] = useState('NPM status: unknown');
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<StatusBar barStyle="dark-content" />
|
<StatusBar barStyle="dark-content" />
|
||||||
@@ -47,6 +51,29 @@ const App: () => React$Node = () => {
|
|||||||
<View style={styles.sectionContainer}>
|
<View style={styles.sectionContainer}>
|
||||||
<FlipperTicTacToe />
|
<FlipperTicTacToe />
|
||||||
</View>
|
</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}>
|
<View style={styles.sectionContainer}>
|
||||||
<Text style={styles.sectionTitle}>Step One</Text>
|
<Text style={styles.sectionTitle}>Step One</Text>
|
||||||
<Text style={styles.sectionDescription}>
|
<Text style={styles.sectionDescription}>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
|
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
Reference in New Issue
Block a user