diff --git a/src/components/InputField/InputField.example.js b/src/components/InputField/InputField.example.js index 021f984a..9c5343b9 100644 --- a/src/components/InputField/InputField.example.js +++ b/src/components/InputField/InputField.example.js @@ -39,6 +39,14 @@ const FormComponent = props => { label="Label for input with initial value" component={InputField} /> + ); diff --git a/src/components/InputField/InputField.js b/src/components/InputField/InputField.js index fae0f2b2..452d7297 100644 --- a/src/components/InputField/InputField.js +++ b/src/components/InputField/InputField.js @@ -1,4 +1,5 @@ import React, { Component, PropTypes } from 'react'; +import { omit } from 'lodash'; import classNames from 'classnames'; import css from './InputField.css'; @@ -16,6 +17,7 @@ class InputField extends Component { labelRootClassName, inputRootClassName, errorRootClassName, + inputComponent: InputComponent, type, label, placeholder, @@ -23,7 +25,22 @@ class InputField extends Component { input, meta, } = this.props; + + const isCustom = type === 'custom'; + const isTextarea = type === 'textarea'; + + if (!isCustom && InputComponent) { + throw new Error('inputComponent should only be given with type="custom" prop'); + } + if (isCustom && !InputComponent) { + throw new Error('inputComponent prop required for custom inputs'); + } + + // Normal component takes all the props, but the type prop + // is omitted from