【发布时间】:2018-08-13 22:33:57
【问题描述】:
我有一个Field 组件,我想构建一个新的CurrencyField
旧的Field 组件
<Field
component={FormField}
id="amount"
label="Amount"
type="text"
name="amount"
{...currencyMask}
maxLength={16}
valid={}
validate={[
required(),
length({ max: 13 }),
numericality({ '>': 0, msg: 'Must be greater than 0!' }),
numericality({ '<=': loan.AccountBalance, msg: `Must be less than or equal to customer's account balance of $${loan.AccountBalance}` }),
]}
/>
新的CurrencyField 相当于上面的Field,我想看起来像这样:
<CurrencyField
id="amount"
label="Amount"
type="text"
name="amount"
/>
或
<Field
component={CurrencyField}
id="amount"
label="Amount"
type="text"
name="amount"
/>
尝试执行此操作时出现错误:
export const CurrencyField = (props) => {
return (
<Field
name={props.input.name}
type={props.type || "text"}
maxLength={16}
{...props}
validate={[
required(),
length({ max: 11 }),
numericality({ '>': 0, msg: 'Must be greater than 0!' })
]}
/>
);
}
【问题讨论】:
标签: reactjs redux redux-form