**出现以下错误:可能未处理的承诺拒绝(id:0:网络请求失败)**有时错误ID更改为ID:3。有人能帮助我吗?
import React, {useState, useEffect} from 'react';
import { SafeAreaView, StyleSheet, Image, AsyncStorage } from 'react-native';
import SpotList from '../components/SpotList';
import logo from '../assets/logo.png';
export default function List () {
const [techs, setTechs] = useState ([]);
useEffect(() => {
AsyncStorage.getItem('techs')
.then((storagedTechs) => {
const techsArray = storagedTechs.split(',').map(tech => tech.trim())
setTechs(techsArray)
})
},[]);
return (
<SafeAreaView style={styles.container}>
<Image style={styles.logo} source={logo}/>
{techs.map(tech => <SpotList key={tech} tech={tech}/>)}
</SafeAreaView>
)
}
const styles = StyleSheet.create ({
container: {
flex: 1,
},
logo: {
height: 32,
resizeMode: 'contain',
alignSelf:'center',
marginTop: 50
},
})
1条答案
按热度按时间js81xvg61#
我会尝试在then块之后添加catch块
这将有助于您进行进一步的调试。