2017-02-27 50 views
0

我有一個函數,循環並抓取對象的一年年屬性。我試圖在我的列表視圖的title道具中呈現它,但我得到這個錯誤。反應本地錯誤原始文本「1997」必須包裝在一個明確的<text>組件

Error: raw text "1997" must be wrapped in an explicit <text> component

我的功能

renderRow = (year) => { 
    return (
     <ListItem 
      key={year.id} 
      title={year.year} 
      onPress={() => this.props.dispatch(storeUserYear(year))} 
      underlayColor='#eceeef' 
     /> 
    ) 
} 

我看到計算器類似的東西,但它與空白React Native error: Raw " " must be wrapped in an explicit <Text> Component

如何擺脫這種錯誤的呢?

謝謝!

+0

「ListItem」是你自己實現的組件嗎? –

+0

ListItem是來自React Native Elements的組件https://github.com/react-native-community/react-native-elements – maxwellgover

+0

這似乎很奇怪,因爲正如馬特所說,問題似乎在組件內部。你確定這是觸發它的代碼嗎?你得到哪個文件/行號? –

回答

0

錯誤在您的ListItem組件中,而不是在這裏。無論您撥打props.title,請確保年份包裹在<Text>...</Text>中。

相關問題