Redux Form - 无法在输入中输入任何内容

2024-01-04

您好,我最近升级到了 redux-form 版本 6.0.0。我面临着一个问题,比如我无法在文本字段中输入任何内容。

P.S 我也在使用 Reactintl。我正在使用 compose 来聚合 connect、reduxform 和 intl 装饰器

这是我的代码Pastebin http://pastebin.com/dwfDRJLg


如果我理解正确,那么从 v6 开始你应该提供额外的onBlur and onChange输入的方法以更新其状态。对于您的无状态组件渲染输入可以这样做:

const renderInput = (field) => {

  const onBlur = () => {
    field.input.onBlur(field.input.value);
  };

  const onChange = (inputValue) => {
    field.input.onChange(inputValue ? inputValue : '')
  };

  return <input {...field.input} onBlur={onBlur} onChange={onChange}
                [...other options omitted for readability] /> 

}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Redux Form - 无法在输入中输入任何内容 的相关文章

随机推荐