Reactjs 将帮助器文本传递到redux表单
我正在使用redux form 6.0.0-rc.4,我想知道是否有方法将附加属性传递给我的Reactjs 将帮助器文本传递到redux表单,reactjs,redux,Reactjs,Redux,我正在使用redux form 6.0.0-rc.4,我想知道是否有方法将附加属性传递给我的字段s 这是我的renderField组件: const renderField = field => ( <div className={field.touched && field.error ? 'invalid' : 'valid'}> <label>{field.input.placeholder}</label> &
字段
s
这是我的renderField
组件:
const renderField = field => (
<div className={field.touched && field.error ? 'invalid' : 'valid'}>
<label>{field.input.placeholder}</label>
<input {...field.input} />
{field.touched && field.error && <span><i className="fa fa-warning"></i> {field.error}</span>}
</div>
);
我希望能够将助手文本直接传递到字段
,以便将其包含在渲染字段
中。文档显示redux表单非常灵活,但似乎没有一个简单的方法来实现这一点
编辑--
当我说“助手文本”时,我指的是一些用于指导用户的副本。例如,在一个日期字段中,我想添加“所选日期必须是从现在起两个工作日”的文字,在一个选择字段中,可能是“请从列表中仅选择一个”。显然,这对于每个领域都是不同的 这很简单:您传递到
字段的所有道具,如果redux表单没有使用,都会简单地传递到组件。我已经在您的示例中添加了帮助文本,向您展示了它是如何工作的
const renderField = field => (
<div className={field.touched && field.error ? 'invalid' : 'valid'}>
<span>{field.helpText}</span>
<label>{field.input.placeholder}</label>
<input {...field.input} />
{field.touched && field.error && <span><i className="fa fa-warning"></i> {field.error}</span>}
</div>
);
const renderField=field=>(
{field.helpText}
{field.input.placeholder}
{field.toucted&&field.error&&{field.error}
);
和字段:
<Field name="addressOne" type="text" placeholder="Address One" component={renderField} helpText="This is my custom help text." />
这是redux form v6的字段中的第3点。您能解释一下“帮助者文本”是什么意思吗?当然-我已经编辑了这个问题,谢谢。啊-我可能应该尝试一下。。看不到森林就看不到这棵树。。非常感谢!一个小问题-在react 15.2中,我得到了一个未知属性
错误-我将其切换到field.input.helpText
,错误消失了。
<Field name="addressOne" type="text" placeholder="Address One" component={renderField} helpText="This is my custom help text." />