简体   繁体   English

React-Native FlatList 白屏不加载数据

[英]React-Native FlatList White Screen doesn't load datas

I want to show this data in FlatList but it shows only whitescreen:我想在 FlatList 中显示这些数据,但它只显示白屏:

const [datas,setDatas] = useState([
        {
            name:'dhinesh',
            phone:'9888888888',
            email:'asdasd@gmail.com',
            salary:'50000',
            position:'ww'
        },
        {
            name:'ramesh',
            phone:'93388888',
            email:'jhjj@gmail.com',
            salary:'90000',
            position:'sw'
        }
    ]);

This is the code i used:这是我使用的代码:

            <FlatList
            data={datas}
            keyExtractor={(item, index) => index.toString()}
            renderItem={({item}) => {
                <View>
                    <Text>{item.name}</Text>
                    <Text>{item.phone}</Text>
                    <Text>{item.email}</Text>
                    <Text>{item.salary}</Text>
                    <Text>{item.position}</Text>
                </View>
            }}
            />

Please give me a solution请给我一个解决方案

Add return in your view在您的视图中添加return

renderItem={({item}) => {
    return (
        <View>
            <Text>{item.name}</Text>
            <Text>{item.phone}</Text>
            <Text>{item.email}</Text>
            <Text>{item.salary}</Text>
            <Text>{item.position}</Text>
         </View>
     )
 }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM