[英]Warning: validateDOMNesting(…): <form> cannot appear as a descendant of <form>
In reactjs, I am using the ant-design
library for a form. 在reactjs中,我将
ant-design
库用于表单。 In the console i face this problem: 在控制台中,我面临这个问题:
Warning: validateDOMNesting(...): <form> cannot appear as a descendant of <form>
Can someone show me what mistake I made in my code? 有人可以告诉我我在代码中犯了什么错误吗?
code 码
import React, { component } from 'react';
import styled from 'styled-components';
import 'antd/dist/antd.css';
import './FirstStep.css';
import { Form, Input } from 'antd';
class RegisterStepOne extends React.Component {
render() {
const { getFieldDecorator } = this.props;
return (
<div>
<FormCard>
<Form onSubmit={this.handleSubmit} className="login-form">
<FormItem>
{getFieldDecorator('firstName', {
rules: [
{
required: true,
message: 'Please input your First name!',
whitespace: true,
},
],
})(<Input placeholder="First name" />)}
</FormItem>
<FormItem>
{getFieldDecorator('lastName', {
rules: [
{
required: true,
message: 'Please input your Last name!',
whitespace: true,
},
],
})(<Input placeholder="Last name" />)}
</FormItem>
<FormItem>
{getFieldDecorator('email', {
rules: [
{
type: 'email',
message: 'The input is not valid E-mail!',
},
{
required: true,
message: 'Please input your E-mail!',
},
],
})(<Input placeholder="Email" />)}
</FormItem>
<FormItem>
{getFieldDecorator('lastPosition', {
rules: [
{
required: true,
message: 'Please input your Last Position!',
whitespace: true,
},
],
})(<Input placeholder="Present or last position" />)}
</FormItem>
<FormItem>
{getFieldDecorator('lastCompany', {
rules: [
{
required: true,
message: 'Please input your Last Company!',
whitespace: true,
},
],
})(<Input placeholder="Present or last Company" />)}
</FormItem>
</Form>
</FormCard>
</div>
);
}
}
export default RegisterStepOne;
Looking at the console screenshot suggests that <RegisterStepOne />
is a child of a <form>
somewhere higher up the component tree. 查看控制台屏幕快照,表明
<RegisterStepOne />
是<form>
的子元素,位于组件树的更高位置。
You are seeing the error because your DOM renders to something like this 您正在看到错误,因为您的DOM呈现了这样的内容
<form>
<div>
<form>
<input />
</form>
</div>
</form>
Which is not valid HTML 哪个是无效的HTML
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.