简体   繁体   English

编译失败。 'Hi' 未在 new.js 文件(TaskList.js)(反应 js 组件)中定义 no-undef

[英]Failed to compile. 'Hi' is not defined no-undef in a new .js file (TaskList.js) (react js component)

TaskList.js任务列表.js

import React from 'react';
export default () => {
return {
    <p>
    Hi
    </p>
     };
   }

I wonder why couldn't I use the HTML code here in this TaskList.js file in order to make the word "Hi" appear in the front end (localhost:3000)?我想知道为什么我不能在此 TaskList.js 文件中使用 HTML 代码来使“Hi”一词出现在前端(localhost:3000)?

I also found the following error in the front end:我还在前端发现了以下错误:

Failed to compile编译失败

    src\TaskList.js
    Line 6:9:  'Hi' is not defined  no-undef
    Search for the keywords to learn more about each error.

and here's another file that's related to TaskList.js这是另一个与 TaskList.js 相关的文件

App.js应用程序.js

   import logo from './logo.svg';
   import './App.css';
   import React from 'react';
   import TaskList from './TaskList.js';

   function App() {
     const tasks = [
       {id: 0, description: 'do this', done: false},
       {id: 1, description: 'do that', done: false}
     ];
    return (
      <div>
          <TaskList />
      </div>
    );
   }

   export default App;

I came up with the above code as I followed the instructor of a course named "Web Development for Blockchain".当我跟随一门名为“区块链的 Web 开发”课程的讲师时,我想出了上面的代码。 Unfortunately, he hasn't answered this question for me yet.不幸的是,他还没有为我回答这个问题。 So, I post this question here as I really need help from you guys on StackOverflow.所以,我在这里发布这个问题,因为我真的需要你们在 StackOverflow 上的帮助。

Return like this (change the {} with () )像这样返回(用()改变{}

return ( 
    <p>
        Hi
    </p>
)

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

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