/* eslint react/no-multi-comp:0, no-console:0 */
import { createForm } from '../index';
import { regionStyle, errorStyle } from './styles';
const Email = {
props: {
form: Object,
hidden: Boolean,
},
render() {
const { hidden, form } = this;
const { getFieldProps, getFieldError, isFieldValidating } = form;
const errors = getFieldError('email');
const style = {
...regionStyle,
display: hidden ? 'none' : '',
};
return (
email:
{errors ?
{errors.join(',')}
: null}
{isFieldValidating('email') ?
validating
: null}
);
},
};
const User = {
props: {
form: Object,
},
render() {
const { getFieldProps, getFieldError, isFieldValidating } = this.form;
const errors = getFieldError('user');
return (
user:
{errors ?
{errors.join(',')}
: null}
{isFieldValidating('user') ?
validating
: null}
);
},
};
const Form = {
props: {
form: Object,
},
methods: {
onSubmit(e) {
e.preventDefault();
this.form.validateFields((error, values) => {
if (!error) {
console.log('ok', values);
} else {
console.log('error', error, values);
}
});
},
},
render() {
const { form } = this;
const { getFieldProps, getFieldValue } = form;
return (
);
},
};
export default createForm()(Form);