diff --git a/src/components/BirthdayInput/BirthdayInput.example.js b/src/components/BirthdayInput/BirthdayInput.example.js index 9fc4d7d4..0ac1acc1 100644 --- a/src/components/BirthdayInput/BirthdayInput.example.js +++ b/src/components/BirthdayInput/BirthdayInput.example.js @@ -1,30 +1,26 @@ /* eslint-disable no-console */ -import React, { Component } from 'react'; +import React from 'react'; import { Field, reduxForm } from 'redux-form'; import * as validators from '../../util/validators'; -import { enhancedField } from '../../util/forms'; +import { InputField } from '../../components'; import BirthdayInput from './BirthdayInput'; -class FormComponent extends Component { - constructor(props) { - super(props); - this.EnhancedBirthdayInput = enhancedField(BirthdayInput); - } - render() { - const required = validators.required('A valid date is required'); - return ( -
- ); - } -} +const FormComponent = () => { + const required = validators.required('A valid date is required'); + return ( + + ); +}; const Form = reduxForm({ form: 'Styleguide.BirthdayInput.Form', diff --git a/src/components/BirthdayInput/BirthdayInput.js b/src/components/BirthdayInput/BirthdayInput.js index 3f26e2ef..bc0a5fb5 100644 --- a/src/components/BirthdayInput/BirthdayInput.js +++ b/src/components/BirthdayInput/BirthdayInput.js @@ -85,14 +85,14 @@ class BirthdayInput extends Component { this.handleSelectChange = this.handleSelectChange.bind(this); } componentWillMount() { - const value = this.props.input.value; + const value = this.props.value; if (value instanceof Date) { this.setState({ selected: selectedFromDate(value) }); } } componentWillReceiveProps(newProps) { - const oldValue = this.props.input.value; - const newValue = newProps.input.value; + const oldValue = this.props.value; + const newValue = newProps.value; const valueChanged = oldValue !== newValue; if (valueChanged && newValue instanceof Date) { this.setState({ selected: selectedFromDate(newValue) }); @@ -103,13 +103,13 @@ class BirthdayInput extends Component { } handleSelectFocus() { window.clearTimeout(this.blurTimeoutId); - this.props.input.onFocus(); + this.props.onFocus(); } handleSelectBlur() { window.clearTimeout(this.blurTimeoutId); this.blurTimeoutId = window.setTimeout( () => { - this.props.input.onBlur(); + this.props.onBlur(); }, BLUR_TIMEOUT ); @@ -117,18 +117,18 @@ class BirthdayInput extends Component { handleSelectChange(type, value) { this.setState(prevState => { const selected = { ...prevState.selected, [type]: parseNum(value) }; - this.props.input.onChange(dateFromSelected(selected)); + this.props.onChange(dateFromSelected(selected)); return { selected }; }); } render() { - const { className } = this.props; + const { rootClassName, className } = this.props; const selectedValue = n => { return typeof n === 'number' ? n : ''; }; - const classes = classNames(css.root, className); + const classes = classNames(rootClassName || css.root, className); return (