I want to set some value for input in the redux-form in the parent component which wraps a form. How can I do i?
You should use initialValues
to initialize a form (and its inputs).
reduxForm({
form: "form",
fields: ["username", "email"],
initialValues: {
username: "John",
email: "[email protected]",
}
})(
props => (
<form onSubmit={props.handleSubmit}>
<input type="text" {props.fields.username} />
<input type="email" {props.fields.email} />
<button type="submit">Send</button>
</form>
)
)
Well, to do it "from the parent component", you would pass the initialValues
as a prop to the decorated form component.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Well, to do it "from the parent component", you would pass the
initialValues
as a prop to the decorated form component.