繁体   English   中英

Redux-Form的字段未编辑

[英]Field of Redux-Form not editing

我有来自Redux-Form的以下Field

          <Field
            name="hours"
            type="number"
            initialValue="100"
            placeholder="Ingrese las horas para esta categoría"
            component={RenderInput}
            onChange={(event) => {
              handleSubmit(currentValues => this.debounceSubmitProduction({
                ...currentValues,
                hours: event.target.value,
              }))();
            }}
          />

我想将初始值传递给Input组件initialValue="100"但是现在,该值出现在输入中,但是我无法对其进行编辑。

这是我的RenderInput组件:

const RenderInput = ({
  input,
  type,
  disabled,
  readOnly,
  placeholder,
  meta: { touched, error },
  onKeyDown,
  innerRef,
  initialValue,
}) => (
  <div>
    <input
      {...input}
      type={type}
      value={initialValue}
      disabled={disabled}
      readOnly={readOnly}
      placeholder={placeholder}
      className={`font-300 ${touched && error && 'has-error'}`}
      onKeyDown={onKeyDown}
      ref={innerRef}
    />
  </div>
);

如何编辑传递给输入的初始值?

问题是您将值设置为等于initialValue ,键入时该值不会更改。 初始化组件时,您需要在redux-store中设置初始值,然后将prop的value设置为等于从商店返回的value onUpdate将更新商店,然后应更新UI以反映更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM