我正面临一种情况,除非组件作为ListVIEw的一部分呈现,否则我的组件将不会呈现文本.例如.这个效果很好:
<ListVIEw dataSource={this.state.dataSource} renderRow={(rowData) => <VIEw style={styles.buttonContainer}> <button onPress={() => navigate('Team', { team: rowData })} Title={rowData.name} /> </VIEw> }/>
但这不起作用,该按钮不会显示任何文本,好像它什么也没收到一样
<VIEw style={styles.container}> <VIEw style={styles.buttonContainer}> <button onPress={() => navigate('Team')} Title={'Sample Text'} /> </VIEw></VIEw>
我的button组件返回如下所示:
return ( <touchableOpacity onPress={onPress} style={buttonStyle}> <Text style={textStyle}> {this.props.Title} </Text> </touchableOpacity>)
我将console.log(this.props.Title)放在render()上,远程调试器控制台中显示以下内容:
未定义的“示例文本”
package.Json中的依赖项
“ react”:“ 16.0.0-Alpha.6”,
“ react-native”:“ ^ 0.43.4”,
“ react-navigation”:“ git https://github.com/react-community/react-navigation.git”
解决方法:
尝试删除这些支架,因为您不需要它们:
Title =“示例文字”
以上是内存溢出为你收集整理的android-如何在React Native中将字符串作为道具传递全部内容,希望文章能够帮你解决android-如何在React Native中将字符串作为道具传递所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)