gpt4 book ai didi

javascript - react native : I have a question with this React

转载 作者:行者123 更新时间:2023-12-02 16:21:38 25 4
gpt4 key购买 nike

有人可以帮忙吗,我几乎尝试了所有方法,但我不能犯任何错误:错误是元素类型无效:需要一个字符串或类/函数,但未定义。检查'App'的渲染方法这是代码:

import React from 'react';
import { useState } from 'react';
import { Flatlist } from 'react-native';
import {StyleSheet, Text, View} from 'react-native';

export default function App() {

const[todos, setTodos] = useState([
{ text: 'buy coffee' , key: '1' },

{ text: 'learn Redux', key: '2' },

{ text: 'go to gym' , key: '3' }

]);

return (
<View style = {styles.container}>

{/*header */}

<View style = {styles.content}>

{/* to form */}


<View style = {styles.list}>

<Flatlist
data = {todos}
renderItem = {( {item} )=> (
<Text>{item.text} </Text>
)}

/>
</View>
</View>
</View>
);
}

const styles = StyleSheet.create({
container: {

flex: 1,
backgroundColor: '#fff'
},
content: {

padding : 40,



}

});

最佳答案

您对 FlatList 的字母“L”使用了错误的大小写

改变

import { Flatlist } from 'react-native';

import { FlatList } from 'react-native';

也改变

   <FlatList
data = {todos}
renderItem = {( {item} )=> (
<Text>{item.text} </Text>
)}

/>

关于javascript - react native : I have a question with this React,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65352785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com