I started a basic react project with npx create-react-app web and running with npm start. I am using react-router-dom to handle navigation and the project is as follows:
index.js
ReactDOM.render(
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
)
App.js:
function Home() {
return (
<div>
<h2>Home</h2>
<div>
I am at home, this should render as expected
</div>
</div>
);
}
function About() {
return (
<div>
<h2>About</h2>
</div>
);
}
function Dashboard() {
return (
<div>
<h2>Dashboard</h2>
</div>
);
}
class App extends Component {
render(){
return(
<main>
<Routes>
<Route path='/' element={Home} />
<Route path='/About' element={About} />
</Routes>
</main>
)
}
}
export default App;
When I go to localhost:3000, I am seeing nothing but a blank page, what am I missing here?