简体   繁体   English

./src/App.js Line 6:19: 'Component' 未定义 no-undef

[英]./src/App.js Line 6:19: 'Component' is not defined no-undef

I need help please.我需要帮助。

import React from 'react';

import logo from './logo.svg';

import './App.css';

import Greet from './components/Greet'


class App extends Component {
  render(){
    return(
      <div className="App">

        <Greet/>

      </div>

    );
  }
}


export default App;

I am facing this error when I run the code:当我运行代码时,我遇到了这个错误:

./src/App.js Line 6:19: 'Component' is not defined no-undef ./src/App.js Line 6:19: 'Component' 未定义 no-undef

What should I do?我该怎么办?

Thanks in advance!提前致谢!

Because you forget to import component from react .因为您忘记从react导入component

Add this line on top of the program在程序顶部添加这一行

import React, { Component } from 'react';

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

相关问题 React js:./src/App.js第22行:未定义&#39;lastWinner&#39;no-undef搜索关键字以了解有关每个错误的更多信息 - React js: ./src/App.js Line 22: 'lastWinner' is not defined no-undef Search for the keywords to learn more about each error ./src/index.js 第 10 行:'elementid' 未定义 no-undef - ./src/index.js Line 10: 'elementid' is not defined no-undef 如何在React“ ./src/components/App.js&#39;Layout&#39;,&#39;Home&#39;中定义组件错误,未定义react / jsx-no-undef - How to fix component error in React "./src/components/App.js 'Layout', 'Home' is not defined react/jsx-no-undef 第5行:“道具”未定义为no-undef - Line 5: 'props' is not defined no-undef src\components\cards.js Line 75:68: 'index' is not defined no-undef 搜索关键字以了解有关每个错误的更多信息 - src\components\cards.js Line 75:68: 'index' is not defined no-undef Search for the keywords to learn more about each error React function - 未定义 no-undef - 组件集成 - React function - is not defined no-undef— component integration React:'p'未在组件文件中定义 no-undef - React: 'p' is not defined no-undef in component file 第 17:20 行:&#39;count&#39; 未定义 no-undef - Line 17:20: 'count' is not defined no-undef 第 27:15 行:'item' 未定义 no-undef - Line 27:15: 'item' is not defined no-undef 第 4:13 行:'React' 未定义 no-undef - Line 4:13: 'React' is not defined no-undef
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM