Redux 表单 - 无法在输入中输入任何内容 [英] Redux Form - Not able to type anything in input

查看:40
本文介绍了Redux 表单 - 无法在输入中输入任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Hi I have upgraded to redux-form version 6.0.0 recently. And I am facing an issue like I am not able to type anything in the text field.

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

P.S I am also using Reactintl. I am using compose to aggregate connect, reduxform and intl decorator

这是我的代码Pastebin

推荐答案

如果我理解正确,那么从 v6 开始你应该提供额外的 onBluronChange 方法用于输入以更新其状态.对于你的无状态组件 renderInput,它可以这样做:

If I understand correctly, then starting with v6 you should provide extra onBlur and onChange methods for the input in order to update its state. For your stateless component renderInput it could be done like this:

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] /> 

}

这篇关于Redux 表单 - 无法在输入中输入任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆