![](/img/trans.png)
[英]Getting undefined is not an object in React native when rendering
[英]React Native: “undefined is not an object” Rendering components with ListView and external dataSource
我有一個應該呈現ListView的Container組件。
ListView的dataSource需要調用帶有“保留”列表的外部(但本地)JSON文件。
ListView應該為帶有標題的JSON文件中的每個條目呈現一個新的“卡片”。
但是,出現以下錯誤:
未定義不是對象(評估“ this.props.dataSource.title”)
以下是我的代碼要點...我在做什么錯?
https://gist.github.com/chapeljuice/316cb72432bf0d3ff90ca93349b85570
我想如果你用
this.props.data.title
要么
this.props.title
代替
this.props.dataSource.title
你可以得到答案。 因為當您將數據傳遞到“ ReservationCard”時,數據將作為其道具。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.