When I try to route and use the components it does not render anything.
Whereas when I try to render all the components individually then it is getting rendered. So the problem is not with the problem I feel.
This is the code for app.js
import Home from "./pages/home/Home";
import Header from "./components/header";
import Contact from "./pages/contact/Contact";
import About from "./pages/about/About";
import { BrowserRouter as Route, Router, Routes } from "react-router-dom";
function App() {
return (
<Router>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/contacts" element={<Contact />} />
<Route path="/about" element={<About />} />
</Routes>
</Router>
);
}
export default App;
This is the code for index.js
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);