Skip to content

Commit e8db698

Browse files
authored
Removed warning about radio buttons (#113)
1 parent 6c8d2a6 commit e8db698

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-final-form",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description":
55
"🏁 High performance subscription-based form state management for React",
66
"main": "dist/react-final-form.cjs.js",

src/Field.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,26 +143,23 @@ export default class Field extends React.PureComponent<Props, State> {
143143
value = ''
144144
}
145145
const input = { name, value, ...this.handlers }
146-
warning(
147-
!_value ||
148-
((rest.type === 'radio' || rest.type === 'checkbox') &&
149-
component === 'input'),
150-
'The value prop on Field is ONLY for use with component="input" and type="radio" or type="checkbox".'
151-
)
152-
if (rest.type === 'checkbox') {
153-
if (_value === undefined) {
154-
input.checked = !!value
155-
} else {
156-
input.checked = Array.isArray(value) && ~value.indexOf(_value)
146+
if (component === 'input') {
147+
if (rest.type === 'checkbox') {
148+
if (_value === undefined) {
149+
input.checked = !!value
150+
} else {
151+
input.checked = Array.isArray(value) && ~value.indexOf(_value)
152+
input.value = _value
153+
}
154+
} else if (rest.type === 'radio') {
155+
input.checked = value === _value
157156
input.value = _value
158157
}
159-
} else if (rest.type === 'radio') {
160-
input.checked = value === _value
161-
input.value = _value
162158
}
163159
if (component === 'select' && rest.multiple) {
164160
input.value = input.value || []
165161
}
162+
166163
if (typeof children === 'function') {
167164
return (children: Function)({ input, meta, ...rest })
168165
}

src/Field.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Field from './Field'
66
const onSubmitMock = values => {}
77

88
describe('Field', () => {
9-
it('should warn error if not used inside a form', () => {
9+
it('should warn if not used inside a form', () => {
1010
TestUtils.renderIntoDocument(<Field name="foo" component="input" />)
1111
})
1212

0 commit comments

Comments
 (0)