简体   繁体   English

“预期作业但找到了表达方式”

[英]“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>&nbsp; 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.

相关问题 React:期待一个赋值或 function 调用,而是看到一个表达式 | 对象作为 React 子项无效(找到:object,键为 {0, 1, - React: Expected an assignment or function call and instead saw an expression | Objects are not valid as a React child (found: object with keys {0, 1, 期望分配,而是在 reactjs 中看到一个表达式 - Expected an assignment and instead saw an expression in reactjs 未使用的表达式,预期的赋值或函数调用 - unused expression, expected an assignment or function call 预期分配或 function 调用,而是看到一个表达式:没有未使用的表达式 - Expected an assignment or function call and instead saw an expression : no unused expression ReactJS错误:“预期分配或函数调用,而是看到了一个表达式” - ReactJS error: “Expected an assignment or function call and instead saw an expression” 期望一个赋值或函数调用,而是在定义接口时看到一个表达式 - Expected an assignment or function call and instead saw an expression when defining interface 反应问题 - 预期分配或 function 调用,而是看到一个表达式 - React issue - Expected an assignment or function call and instead saw an expression 修复 - 预期分配或 function 调用,而是看到一个表达式 - Fix - expected an assignment or function call and instead saw an expression ReactJs - 预期分配或 function 调用,而是看到一个表达式 - ReactJs - Expected an assignment or function call and instead saw an expression 2022 React - 期望一个赋值或 function 调用,而是看到一个表达式 - 2022 React - Expected an assignment or function call and instead saw an expression
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM