[英]“Expected an assignment but found an expression”
I'm working on a project with my classmates, but while trying to load this page in react I get the error: "Expected an assignment or function call and instead saw an expression" that's appeared on several of her pages. 我正在与同班同学一起进行一个项目,但是在尝试以响应方式加载此页面时,我得到了一个错误:“预期分配或函数调用,而是看到了一个表达式”,该错误出现在她的多个页面上。 I looked into it and it seems to be a warning that ES Lint throws out, but I'm unsure of how to fix it for my particular issue.
我调查了一下,似乎警告说ES Lint丢了,但我不确定如何针对我的特定问题解决它。 Any help would be appreciated.
任何帮助,将不胜感激。
Code Snippet:: 代码段:
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> login</button>
</div>
</fieldset>
</form>
<GlobalFooter />
</div>
}
export default LoginPage;
You forgot to enclose them in a return statement. 您忘记将它们包含在return语句中。
const LoginPage = props => {
// this is where you put your logic if needed before returning JSX codes
return (
<div>
// ...rest of the codes
</div>
);
};
or, you can simply do this, since you're using ES6 arrow function: 或者,您可以简单地执行此操作,因为您正在使用ES6箭头功能:
const LoginPage = props => (
<div>
// ...rest of the code
</div>
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.