Skip to content

Commit

Permalink
Add dev warning when type prop is missed for checkbox, radio or multi…
Browse files Browse the repository at this point in the history
…ple select
  • Loading branch information
Andarist committed Mar 27, 2018
1 parent a66f713 commit 432ab0b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ export default class Field extends React.Component<Props, State> {
},
onChange: (event: SyntheticInputEvent<*> | any) => {
const { parse, value: _value } = this.props

if (process.env.NODE_ENV !== 'production' && event && event.target) {
const { type } = event.target
const props: Object = this.props
const unknown =
~['checkbox', 'radio', 'select-multiple'].indexOf(type) && !props.type

warning(
!unknown,
`You must pass \`type={"${type}"}\` prop to your Field(${
props.name
}) component.\n` +
`Without it we don't know how to unpack your \`value\` prop - ${
props.value
}.`
)
}

const value: any =
event && event.target
? getValue(
Expand Down

0 comments on commit 432ab0b

Please sign in to comment.