简体   繁体   English

React Native:“未定义不是对象”使用ListView和外部dataSource渲染组件

[英]React Native: “undefined is not an object” Rendering components with ListView and external dataSource

I have a Container component that should render a ListView. 我有一个应该呈现ListView的Container组件。

The ListView's dataSource needs to call an external (But local) JSON file with a list of "reservations". ListView的dataSource需要调用带有“保留”列表的外部(但本地)JSON文件。

The ListView should render a new "card" for each entry in the JSON file with a title. ListView应该为带有标题的JSON文件中的每个条目呈现一个新的“卡片”。

However, I get the following error: 但是,出现以下错误:

undefined is not an object (evaluating 'this.props.dataSource.title') 未定义不是对象(评估“ this.props.dataSource.title”)

Below is a gist of my code ... what am I doing wrong? 以下是我的代码要点...我在做什么错?

https://gist.github.com/chapeljuice/316cb72432bf0d3ff90ca93349b85570 https://gist.github.com/chapeljuice/316cb72432bf0d3ff90ca93349b85570

i think if you use 我想如果你用

this.props.data.title

or 要么

this.props.title

instead of 代替

this.props.dataSource.title

you can get answer. 你可以得到答案。 because when you pass data to 'ReservationCard', data will be as props to it. 因为当您将数据传递到“ ReservationCard”时,数据将作为其道具。

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

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