“期望分配但找到了表达式”

时间:2018-10-29 05:03:27

标签: reactjs

我正在与同班同学一起在一个项目上工作,但是在尝试以响应方式加载此页面时,我得到了一个错误:“期望分配或函数调用,而是看到了一个表达式”,该错误出现在她的多个页面上。我调查了一下,似乎警告说ES Lint丢了,但我不确定如何针对我的特定问题解决它。任何帮助,将不胜感激。

代码段:

import React from "react";
import './LoginPage.css';
import GlobalNav from '../../components/GlobalNav';

import GlobalFooter from '../../components/GlobalFooter/GlobalFooter';

const LoginPage = props => {

<div>

<GlobalNav />

<h1 className="uk-text-center blueText">login</h1>
<div className="uk-container"/>
<form className="authorForm uk-width-1-2@m uk-align-center uk-form-stacked">

<p className="uk-text-lead">Login and add some Highlights of your own.</p>

 <p className="uk-text-center redText"><span uk-icon="bolt"></span></p>

<fieldset className="uk-fieldset">
<div className="form-group">

<div className="uk-margin">

<label className="uk-form-label" for="form-stacked-select">* Email:</label>
 <div className="uk-inline uk-width-1-1">
 <span className="uk-form-icon uk-form-icon-flip blueText" uk-icon="icon: world"></span>
 <input className="uk-input" id="email" name="email" type="text"></input>
   </div>
 </div>

<div className="uk-margin">
 <label className="uk-form-label" for="form-stacked-select">* Password:</label>
 <div className="uk-inline uk-width-1-1">
 <span className="uk-form-icon uk-form-icon-flip blueText" uk-icon="icon: lock"></span>
<input className="uk-input" id="password" name="password" type="text"></input>
</div>
</div> 

 <button className="uk-button uk-button-secondary redText uk-align-center" id="submit-btn"><span uk-icon="user"></span>&nbsp; login</button>

 </div>

 </fieldset>

</form>

 <GlobalFooter />

 </div>
}

export default LoginPage;

1 个答案:

答案 0 :(得分:1)

您忘了将它们包含在return语句中。

const LoginPage = props => {
  // this is where you put your logic if needed before returning JSX codes
  return (
    <div>
      // ...rest of the codes
    </div>
  );
};

或者,因为您使用的是ES6箭头功能,您可以简单地做到这一点:

const LoginPage = props => (
  <div>
    // ...rest of the code
  </div>
);