繁体   English   中英

在React中整理

[英]Linting in React

我正在学习React.js。 我正在开发一个应用程序。 我的代码如下

<div className="ui pagination menu">
            <span
              className={
                this.props.page === 1
                  ? 'disabled item pagination'
                  : 'item pagination'
              }
              onClick={() => {
                if (this.props.page === 1) {
                  return false;
                }
                this.pagination(this.props.page - 1);
              }}
            >
              ❮
            </span>
            <div className="item">
              Page {this.props.page} of {this.props.maxPages}
            </div>
            <span
              className={
                this.props.page === this.props.maxPages
                  ? 'disabled item pagination'
                  : 'item pagination'
              }
              onClick={() => {
                if (this.props.page === this.props.maxPages) {
                  return false;
                }
                this.pagination(this.props.page+1); 

                <h1 className="ui attached warning message table">  // Line 185
                  <span id="address">Addresses</span>
                  <span id="user_details">
                    Welcome,  <b> { this.state.userName } </b>  |
                    <span id="logout" onClick={this.logout}> Logout </span>
                    <button className="ui teal button" onClick={this.openPopup}> <i className="plus square icon" />
                      Add Address
                    </button>
                  </span>
                </h1>
              {this.props.addresses.length > 0 ? (

我收到如下Warning

Line 185:  Expected an assignment or function call and instead saw an expression  no-unused-expressions

谁能说我该如何解决Warning

我认为您在line 185之前错过了onClick函数的关闭,应该这样做,

<span
  className={
      this.props.page === this.props.maxPages
      ? 'disabled item pagination'
      : 'item pagination'
  }
  onClick={() => {
    if (this.props.page === this.props.maxPages) {
        return false;
    }
    this.pagination(this.props.page+1); 
}} //This is missing
> //closing of span is also missing
<h1 className="ui attached warning message table">  // line 185

我相信您错过了onClick的总结声明。 使用和集成开发环境可能会有所帮助。 这将帮助您查看缺少语法的地方。 此外,以下是有关错误原因的更多信息:

http://linterrors.com/js/expected-an-assignment-or-function-call

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM