Skip to content

Instantly share code, notes, and snippets.

@wmzy
Last active January 18, 2017 08:11
Show Gist options
  • Save wmzy/57de808080b2920f9d321bc5a3b569c3 to your computer and use it in GitHub Desktop.
Save wmzy/57de808080b2920f9d321bc5a3b569c3 to your computer and use it in GitHub Desktop.
import React, {Component, PropTypes} from 'react';
import {Form} from 'formsy-react';
import classNames from 'classnames';
class FormEx extends Form {
static defaultProps = {
...Form.defaultProps,
prefixCls: 'ant-form'
};
static propTypes = {
prefixCls: React.PropTypes.string,
inline: PropTypes.bool,
horizontal: PropTypes.bool
};
render() {
const form = super.render();
const {prefixCls, inline, horizontal, className, ...props} = form.props;
// 'inline' has been deleted from props,but there is a warn still.
const cn = classNames({
[`${prefixCls}-horizontal`]: horizontal,
[`${prefixCls}-inline`]: inline,
[className]: !!className
});
return React.cloneElement(form, {...props, className: cn});
}
}
export default FormEx;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment