2017-05-18 63 views
0

tryingn的財產使用API​​調用來呈現列表視圖陣營本地無法讀取未定義

(rowData)=><CatalogCell newWidth={imgWidth} imgMargin = 
    {imgMargin} 
    url={rowData.product.name} price={rowData.price}/> 

我可以正確讀取的價格,但如果我讀什麼超越的深度1,我得到這個錯誤,basiclly rowData.product不會給我任何東西,但如果我去rowData.product,它會顯示錯誤

Cannot read property 'name' of undefined 

renderRow 
    CatalogList.js:74:114 
StaticRenderer.render 
    StaticRenderer.js:32:22 
<unknown> 
    ReactCompositeComponent.js:1218:19 
measureLifeCyclePerf 
    ReactCompositeComponent.js:63:11 
ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext 
    ReactCompositeComponent.js:1217:24 
ReactCompositeComponentWrapper._renderValidatedComponent 
    ReactCompositeComponent.js:1249:31 
ReactCompositeComponentWrapper.performInitialMount 
    ReactCompositeComponent.js:499:29 
ReactCompositeComponentWrapper.mountComponent 
    ReactCompositeComponent.js:346:20 
Object.mountComponent 
    ReactReconciler.js:56:34 
Constructor.mountChildren 
    ReactMultiChild.js:276:41 

代碼來設置列表視圖數據:

componentDidMount(){ 
     getCatalog((callback)=>{ 
      console.warn(callback.result.data) 
      this.setState({ 
       dataSource:this.state.dataSource.cloneWithRows(
        callback.result.data 
       ), 
       loading:false, 
      }) 
     }) 
    } 
+1

你可以console.log並告訴我什麼是數據rowdata獲得,也可以告訴我你如何設置值rowData – zenwraight

回答

0

Nvm,應該有一個標誌,告訴數據是否準備就緒。深度1的作品,因爲道具總是存在