不变违规:元素类型无效:预期为字符串

时间:2018-01-29 05:09:07

标签: react-native

我对ui小猫套件库有这个问题,它可以正常使用但在我通过道具时抛出此错误。我试图改变我的导入/导出方法,没有运气。可以请某人帮忙搞清楚。

import { RkTheme, RkButton, RkCard, RkText, rkCardContent, rkCardImg, rkCardFooter, } from 'react-native-ui-kitten';

...

export default class AutocompleteExample extends Component {
render() {
  return (
  <Content />
    <RkCard>
  <View rkCardHeader>
    <Text>Header</Text>
  </View>
  <Image rkCardImg source={{uri: this.state.img}}/>
  <View rkCardContent>
    <Text>quick brown fox</Text>
  </View>
  <View rkCardFooter>
    <Text>{this.state.price}</Text>
  </View>
</RkCard>

 )
}

module.exports = AutocompleteExample

this.state.img运行良好,我能够看到图片但是this.state.price不起作用,如果用它有效的常规文本替换它。感谢。

1 个答案:

答案 0 :(得分:0)

重写上述代码

import { RkTheme, RkButton, RkCard, RkText, rkCardContent, rkCardImg, rkCardFooter, } from 'react-native-ui-kitten';

...

export default class AutocompleteExample extends Component {

state = {
  price: '',
}

render() {
  return (
  <Content />
    <RkCard>
  <View rkCardHeader>
    <Text>Header</Text>
  </View>
  <Image rkCardImg source={{uri: this.state.img}}/>
  <View rkCardContent>
    <Text>quick brown fox</Text>
  </View>
  <View rkCardFooter>
    <Text>{this.state.price}</Text>
  </View>
</RkCard>

 )
}

module.exports = AutocompleteExample