我遇到了一个问题。我正在尝试使用React Router,但它一直显示空白页面。以下是我的代码:
App.js:
App.js:
import React from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import HomePage from "./HomePage";
function App() {
return (
<Router>
<Routes>
<Route path="/" element={<HomePage />} />
</Routes>
</Router>
);
};
export default App;
HomePage.js:
import React from "react";
import {withRouter} from "react-router-dom"
const HomePage = () => {
return <div>hi</div>
}
export default HomePage;
index.js:
import React from "react";
import ReactDom from "react-dom";
import App from './App';
ReactDom.render(<App/>, document.getElementById("root"))
我安装了"React Router V6",有人能告诉我出了什么问题吗?感谢所有帮助者。