Trey Granderson
Trey Granderson

Reputation: 710

How to make fields in redux-form be active by default?

I would like to make my redux-form fields 'active' by default. Is there a way to do this using RF v.6.5.0 ? Thank you!

Upvotes: 1

Views: 421

Answers (1)

Yo Wakita
Yo Wakita

Reputation: 5450

At the moment I don't think there is a property to set on refux-form Fields to set it to active by default. You can set it via refs once the component is mounted though.

Edit: Here might be a cleaner implementation using getRenderedComponent()

componentDidMount() {
  this.refs.defaultInput
    .getRenderedComponent()
    .focus()
}

<Field name="defaultInput" ref="defaultInput" withRef component="input"/>

From redux-form Github There are a few other examples and link in that Github issue.

Upvotes: 2

Related Questions