davidkpiano / react-redux-form

Create forms easily in React with Redux.
https://davidkpiano.github.io/react-redux-form
MIT License
2.06k stars 252 forks source link

Fix uncontrolled input warning #1151

Closed Chris-Berragan-OnStep closed 6 years ago

Chris-Berragan-OnStep commented 6 years ago

Thank you for this library! I've been getting an uncontrolled input warning on changing input fields and found a fix by providing a fallback to empty string when value is undefined.

Possibly a duplicate of #739, #714, and #630.

davidkpiano commented 6 years ago

Thanks!

peggers123 commented 6 years ago

Hello,

This update has confused me. I am trying to build a Select control that outputs a boolean, but also has an empty value when I want to force the user to select an option:

                <Control.select model={this.props.model}  validators={validator} parser={parse} formatter={formater} type="number">
                    <option value='' hidden disabled>{this.props.t('_option select')}</option>
                    <option value={false}>{this.props.t('_option false')}</option>
                    <option value={true}>{this.props.t('_option true')}</option>
                </Control.select>

But now it is updating with strings rather than booleans - how do I alter this?