2017-02-27 45 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>中。

相关问题