更新属性'占位符'时出错管理的视图:AndroidTextInput

时间:2017-07-14 07:51:06

标签: javascript reactjs react-native react-redux jsx

我正在尝试访问native-base Item组件中的prop并抛出

    Error while updating property 'placeholder' of a view managed
    by:AndroidTextInput

    TypeError: expected dynamic type `string', but had type `int64'

这里是返回此错误的代码

import React, { Component } from 'react';
import { Container, Content, Form, Item, Input, Button, Text } from 'native-base';

export default class EditProduct extends Component {
  componentDidMount() {
    Actions.refresh({
     title: 'Edit Product',
     leftTitle: '<',
     onLeft: () => {},
   });
}

render() {
  const id = this.props.id || 'No ID';
  const min = this.props.min || 'No Min';
  const max = this.props.max || 'No Max';

  return (
    <Container>
     <Content>
      <Form>
        <Item>
          <Input placeholder=id />
        </Item>
        <Item>
          <Input placeholder=max />
        </Item>
        <Item last>
          <Input placeholder=min />
        </Item>

        <Button block>
          <Text>Confirm</Text>
        </Button>
      </Form>
     </Content>
   </Container>
 );
 }
}

如何从int64转换字符串?除了转换之外还有其他选择吗?

1 个答案:

答案 0 :(得分:1)

输入的道具占位符接收字符串,只需将其转换为字符串即可。

const id = this.props.id + ""