E
E
Evgeny Ermolaev2018-06-29 20:38:13
Frontend
Evgeny Ermolaev, 2018-06-29 20:38:13

How to set default value to text field in React final form?

Good afternoon everyone! I used the react-final-form library on a React project, everything was fine until I needed to add a default value to the field. I can't add it at all. If anyone knows please help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2018-06-29
@patch94

initialValues

(
  <Form
    onSubmit={onSubmit}
    subscription={{ dirty: true }}
    initialValues={{ foo: 'bar' }}
  >
    {({ handleSubmit }) => (
      <form onSubmit={handleSubmit}>
        <Field name="foo" component="input" />
        <button type="submit">Submit</button>
      </form>
    )}
  </Form>
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question