简体   繁体   English

语义UI反应语法错误:相邻JSX元素必须包装在一个封闭标签中

[英]semantic-ui-react Syntax error: Adjacent JSX elements must be wrapped in an enclosing tag

I'm using semantic-ui-react to build a form for a new user: 我正在使用语义UI反应来为新用户构建表单:

import React from 'react';
import { Form } from 'semantic-ui-react';
import {createUser} from '../../../actions/userAction';

class UserAddModalForm extends React.Component {
  constructor(props) {
    super(props);
  }

  handleSubmit(event, props) {
    event.preventDefault();
    let body = {
        lastname: event.target.lastName.value,
        firstname: event.target.firstName.value,
        username: event.target.userName.value,
        email: event.target.email.value,
    }
    props.dispatch(createUser(body));
    props.onCancel();
  }

  render() {
    return(
      <div>
        <Form onSubmit={ (event) => this.handleSubmit(event, this.props)>
          <Form.Field>
            <label>Last Name</label>
            <input name='lastName' />
          </Form.Field>
          <Form.Field>
            <label>First Name</label>
            <input name='firstName' />
          </Form.Field>
          <Form.Field>
            <label>Username</label>
            <input name='userName' />
          </Form.Field>
          <Form.Field>
            <label>Email Address</label>
            <input name='email' />
          </Form.Field>
          <Button type='submit'>Submit</Button>
          <Button onClick={ this.props.onCancel }>Cancel</Button>
        </Form>
      </div>
    )
  }
}

export default UserAddModalForm;

When I build I receive this error: 构建时收到此错误:

./src/components/ui/users/UserAddModalForm.js
Syntax error: Adjacent JSX elements must be wrapped in an enclosing tag (30:10)

  28 |             <input name='lastName' />
  29 |           </Form.Field>
> 30 |           <Form.Field>
     |           ^
  31 |             <label>First Name</label>
  32 |             <input name='firstName' />
  33 |           </Form.Field>

I've googled around and as far as I can tell I am enclosing my JSX element in a div. 我已经四处搜寻,据我所知,我将JSX元素包含在div中。 I've used semantic-ui-react components in other parts of my application with no error, I'm at a loss for why the build is hanging up on this. 我在应用程序的其他部分中使用了语义UI反应组件,没有出现任何错误,我迷茫了为什么构建会挂在它上面。

Any and all help would be greatly appreciated. 任何和所有帮助将不胜感激。 Thank you. 谢谢。

<Form onSubmit={ (event) => this.handleSubmit(event, this.props)>

应该

<Form onSubmit={ (event) => this.handleSubmit(event, this.props)}>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 相邻的JSX元素必须包装在一个封闭的标记React Native中 - Adjacent JSX elements must be wrapped in an enclosing tag React Native 错误:相邻的JSX元素必须包装在封闭标记中 - Error: Adjacent JSX elements must be wrapped in an enclosing tag 解析错误:必须将相邻的 JSX 元素包装在封闭标记中 - Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag 解析错误:相邻的 JSX 元素必须包含在封闭标记中 - Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag 解析错误:必须将相邻的 JSX 元素包装在封闭标记中(React.js) - Parse Error:Adjacent JSX elements must be wrapped in an enclosing tag(React.js ) 如何修复错误:相邻的 JSX 元素必须包含在封闭标记中? 在本机反应 - How to fix the error: Adjacent JSX elements must be wrapped in an enclosing tag ? in react native React.js错误“相邻的JSX元素必须包装在一个封闭的标签中” - React.js Error “Adjacent JSX elements must be wrapped in an enclosing tag” 在反应中用大括号解析错误:必须将相邻的 JSX 元素包装在封闭标记中。 你想要一个 JSX 片段 &lt;&gt;...? - parsing error with braces in react: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? React.js 解析错误:必须将相邻的 JSX 元素包装在封闭标记中。 你想要一个 JSX 片段 &lt;&gt;...</> ? - React.js Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? 相邻的 JSX 元素必须被包裹在一个封闭标记中,当它被包裹在一个结束标记中 - Adjacent JSX elements must be wrapped in an enclosing tag error, when it wrapped in a closing tag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM