【发布时间】:2018-11-09 05:47:44
【问题描述】:
有一个添加拍卖页面,添加拍卖时打开添加拍卖页面时默认显示拍卖编号。
在我的情况下,仅在单击并尝试添加数字或退出该字段后才会显示该数字。并且该数字将根据我们已经添加的计数来自火力基地,当前拍卖数量应该像现有拍卖加一(现有拍卖计数 + 1)。提前致谢!!
render() {
const { handleSubmit } = this.props;
let chittieAuctionNumber = Object.keys(this.props.chittieAuctions).length;
let chittieAuctionUsers = [];
let chittieId = this.props.match.params.chittieId;
let chittieUsers = this.props.chitties[chittieId].chittieUsers;
Object.keys(this.props.chittieAuctions).map((key) => {
chittieAuctionUsers.push(this.props.chittieAuctions[key].userData);
});
Object.keys(this.props.chitties[chittieId].chittieUsers).map((key) => {
let existingUserData = find(chittieAuctionUsers, ['id', key]);
if (existingUserData && existingUserData.id === key) {
delete chittieUsers[key];
}
});
const auctionNumber = (value) =>
value == null ? '' : chittieAuctionNumber + 1;
return (
<form onSubmit={handleSubmit}>
<Card>
<CardHeader>
<Row>
<Col xs="6" lg="5">
<Button color="primary" onClick={this.goBack}>
<i className="fa fa-chevron-left" />
Back
</Button>
</Col>
<Col xs="6" lg="7">
<h4 className="font-weight-bold">Add Auction</h4>
</Col>
</Row>
</CardHeader>
<CardBody>
<FormGroup row className="my-0">
<Col xs="12" lg="6">
<Field
name="auctionNumber"
type="text"
component={FormInput}
label="Auction Number *"
normalize={auctionNumber}
/>
</Col>
【问题讨论】:
标签: javascript reactjs firebase redux-form