Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 要将数据传递给其他组件-ListView_Ios_Listview_React Native_React Native Android_React Native Ios - Fatal编程技术网

Ios 要将数据传递给其他组件-ListView

Ios 要将数据传递给其他组件-ListView,ios,listview,react-native,react-native-android,react-native-ios,Ios,Listview,React Native,React Native Android,React Native Ios,我已经添加并导入了示例数据。我想在列表视图中列出此文件中的数据,并将数据传递给RenderRow的行组件。但是得到错误的说法 行(…):必须返回有效的React元素(或null)。您可能返回了未定义、数组或其他无效对象 Row.js: const Row = (props) => { <View Style={styles.container}> <Image source={{ uri: props.picture.large}} /> <Text

我已经添加并导入了
示例数据
。我想在
列表视图中列出此文件中的数据,并将数据传递给
RenderRow
的行组件。但是得到错误的说法

行(…):必须返回有效的React元素(或null)。您可能返回了未定义、数组或其他无效对象

Row.js:

const Row = (props) => {
 <View Style={styles.container}>
  <Image source={{ uri: props.picture.large}} />
  <Text >
   {`${props.name.first} ${props.name.last}`}
  </Text>
 </View>
}
const行=(道具)=>{
{${props.name.first}${props.name.last}}
}
有什么问题吗

将此行更改为

renderRow={(data) => <Row {...data} />}
renderRow={(数据)=>}
对此

 renderRow={(data) =><Row {...this.props} />}
renderRow={(数据)=>}

这可能有助于您获取行中的道具组件

ES6仅在没有显式块时返回:

const cb = (param) => param * 2;
您应该显式返回:

const Row = (props) => {
    return (
        <View Style={styles.container}>
            <Image source={{ uri: props.picture.large}} />
            <Text >
                {`${props.name.first} ${props.name.last}`}
            </Text>
        </View>
    );
}
const行=(道具)=>{
返回(
{${props.name.first}${props.name.last}}
);
}

检查此项以获得进一步的解释。

您需要发布您的
组件的外观以及实际
数据
外观的示例。否则,它可能是任何东西。@MichaelCheng更新。请现在检查一下,大副。成功了!也谢谢你的资源。
const cb = (param) => param * 2;
const Row = (props) => {
    return (
        <View Style={styles.container}>
            <Image source={{ uri: props.picture.large}} />
            <Text >
                {`${props.name.first} ${props.name.last}`}
            </Text>
        </View>
    );
}