与 react-final-form 一起使用时 defaultValue 未填充在 textarea 中

defaultValue is not filled in textarea when used with react-final-form

我无法将默认值设置为文本区域,我正在使用 react-final-form 并将 TextareaField 包装在 react-final-form 的 Field 元素中

这是我的代码:

class App extends React.Component {
  submitForm(values) {
   .....
  }

 renderForm({ handleSubmit }) {
  return (
   <form
    onSubmit={handleSubmit}
   >
    <Field
      name="description"
    >
      {({ input, meta }) => (
        <TextareaField
          label='Description'
          error={meta.error}
          isInvalid={meta.submitFailed && !meta.valid}
          inputAttrs={{
            placeholder: 'Desc..',
          }}
          defaultValue='my text'
          onChange={(e) => { input.onChange(e.target.value); }}
          value={input.value}
          required
        />
      )}
    </Field>
    <Button text="Submit" type={Button.Opts.Types.SUBMIT} />
  </form>
 );
}
render() {
  return (
    <Form
      onSubmit={this.submitForm}
      render={this.renderForm}
      validate={(values) => {
        const errors = {};
        if (!values.description) {
          errors.description = 'Required';
        }
        return errors;
      }}
    />
   );
 }
}

卡死了,我哪里漏了??

如果您希望 my text 成为您字段中的初始值,您需要将 initialValues={{ description: 'my text' }} 传递给 Form 组件。