简体   繁体   English

当我尝试运行我的 React 项目时出现错误

[英]I am getting an error when I try to run my react project

The error is coming from the first line of my App.js file I am getting an error on the first line when I try to import react.错误来自我的 App.js 文件的第一行 我在尝试导入反应时在第一行收到错误。 I have made sure that all dependencies are installed and I have also restarted vs code.我已确保安装了所有依赖项,并且还重新启动了 vs 代码。

Uncaught SyntaxError c:\Users\Dell i7\react-category-v1\src\App.js:1 import React from 'react'未捕获的语法错误 c:\Users\Dell i7\react-category-v1\src\App.js:1 import React from 'react'

import React from 'react'
import { connect } from 'react-redux'


import './App.css';
import Navbar from './components/Navbar';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import Home from './pages/Home';
import Reports from './pages/Reports';
import Products from './pages/Products';

function App() {
  return (
    <>
      <Router>
        <Navbar />
        <Switch>
          <Route path='/' exact component={Home} />
        
        </Switch>
      </Router>
    </>
  );
}

export default App;

use Routes instead of Switch, i think Switch is no longer available.使用 Routes 而不是 Switch,我认为 Switch 不再可用。 if you are using latest version of react-route-dom如果你使用的是最新版本的 react-route-dom

<Router>
      <Navbar />
      <Home/>
     <Routes>
        <Route path="/" exact component={Home} />
       </Routes>
    </Router>

暂无
暂无

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

相关问题 为什么我在系统中第一次运行 react js 项目时收到此错误消息? - Why I am getting this error message when I run react js project first time in my system? 当我尝试在 android 上运行 React Native 应用程序时出错 - getting error when i try to run react native app on android 为什么在尝试运行新的 React Native 项目时出现错误 - Why am I getting an error when trying to run a new react native project 尝试运行我的机器人命令时出现此错误 - I am getting this error when trying to run my bot commands 当我尝试在“node.js”中运行这行代码时,我收到以下错误 - When I try to run this line of code in “node.js”, I am getting the following error 当我尝试安装反应图标时收到一条错误消息 - I am getting an error message when I try to install react icons 当我尝试读取 Firebase 上的数据时,出现“未捕获的 ReferenceError:firebase 未定义”错误 - I am getting "Uncaught ReferenceError: firebase is not defined" error when i try to read my datas on Firebase 我的服务器已启动,但是当我尝试连接它时,出现错误[Node.js] - My Server is up but when I try to connect to it I am getting an error [Node.js] 为什么当我尝试运行服务器 gRPC 时出现此错误? - why i'm i getting this error when i try to run my server gRPC? 为什么我在控制台中未定义,当我尝试使用 typescript 订阅和使用我的上下文并做出反应时 - Why am i getting undefined in my console, when i try to subscribe and use my context using typescript and react
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM