Last active
January 18, 2017 08:11
-
-
Save wmzy/57de808080b2920f9d321bc5a3b569c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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