I know there's a ton of similar questions like this but I'm super stumped and I simply cannot get this to work. If I code the component Home in the return like this, my page renders fine:
App.jsx
import './App.css';
import Home from './pages/Home.jsx'
function App() {
return (
<Home />
);
}
export default App;
But when I move it into the router structure it will not load no matter what I've tried
App.jsx
import './App.css';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Home from './pages/Home.jsx'
function App() {
return (
<Router>
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</Router>
);
}
export default App;
Home.jsx
function Home() {
return (
<div style={{ padding: 20 }}>
<h2>Home View</h2>
<p>Lorem ipsum dolor sit amet, consectetur adip.</p>
</div>
);
}
export default Home;
index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App.jsx';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);