简体   繁体   中英

How can I solve this error in React App? ('Component' is not defined no-undef)

Navbar.js

import React,{ Component } from "react";

class Navbar extends Component {
  state = {};
  render() {
    return (
      <>
        <div>
          <nav className="navbar navbar-expand-lg navbar-dark bg-dark">
            <div className="container-fluid">
              <a className="navbar-brand" href="#">
                Hetazon
              </a>
            </div>
          </nav>
        </div>
      </>
    );
  }
}

export default Navbar;

App.js

import './App.css';
import Navbar from './Components/Navbar';

function App() {
  return (
    <>
      <Navbar/>
    </>
  );
}

export default App;

error is *

ERROR in [eslint]
src\Component\Navbar.js
  Line 2:22:  'Component' is not defined  no-undef

Search for the keywords to learn more about each error.

I even try class Navbar extends React.Component in line 3 Navbar.js but the same error was received.

Please help me to solve this error, I tried so much to solve it but I can't...

It seems eslint has problem with it, and your code is ok

you might need eslint-plugin-react package to be installed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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