当我在debugger mode
时,这是我的屏幕外观:
当我不在debugger mode
时,我的屏幕如下所示:
App.js
import React, {useEffect, useState} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {getThoughts} from './src/util/functions';
import firebase from './src/util/firebase';
const App = () => {
const [thoughts, setThoughts] = useState([]);
// Fetch api data
useEffect(() => {
const fetchData = async () => {
const db = firebase.firestore();
const data = await db.collection('thoughts').get();
setThoughts(
data.docs.map((doc) => {
return doc.data();
}),
);
};
fetchData().catch((error) => error);
}, []);
return (
<View style={styles.container}>
<View style={styles.content}>
{thoughts.length > -1 ? (
thoughts.map((val) => {
return (
<Text style={styles.text} key={val.thought}>
{val.thought}
</Text>
);
})
) : (
<Text style={styles.text}>Loading...</Text>
)}
</View>
</View>
);
};
我已经有大约一天的时间了。我非常感谢您提供任何帮助,解释我为什么遇到这个问题以及如何解决这个问题。