Improve checkbox value resolveing

Add better props validation and value resolving for FieldCheckbox.
This commit is contained in:
Hannu Lyytikainen 2018-04-09 15:57:26 +03:00
parent 6fb43f4aaf
commit 8cbe50aed4

View file

@ -1,5 +1,5 @@
import React from 'react';
import { node, string, object } from 'prop-types';
import { any, node, string, object, shape } from 'prop-types';
import classNames from 'classnames';
import { Field } from 'redux-form';
import { ValidationError } from '../../components';
@ -40,7 +40,7 @@ const FieldCheckboxComponent = props => {
const classes = classNames(rootClassName || css.root, className);
const { value, ...inputProps } = input;
const checked = !!value;
const checked = value === true;
const checkboxProps = {
id,
@ -80,7 +80,7 @@ FieldCheckboxComponent.propTypes = {
label: node,
// redux-form Field params
input: object.isRequired,
input: shape({ value: any }).isRequired,
meta: object.isRequired,
};