I’m learning React. I cannot understand why react router v6 is not rendering any component.
src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { Customers, Invoices, Jobs, Login, Sales, } from './modules'
import './App.css';
import './index.css';
import App from './App';
const rootElement = document.getElementById("root");
ReactDOM.render(
<BrowserRouter>
<Routes>
<Route path="/" element={<App />}>
<Route path="/jobs" element={<Jobs />} />
<Route path="customers" element={<Customers />} />
<Route path="invoices" element={<Invoices />} />
<Route path="sales" element={<Sales />} />
<Route
path="*"
element={
<main style={{ padding: "1rem" }}>
<p>There's nothing here!</p>
</main>
}
/>
</Route>
</Routes>
</BrowserRouter>,
rootElement
);
src/modules/invoices/Invoices.js
import { Link } from "react-router-dom";
import { getInvoices } from "../../data";
export default function Invoices() {
let invoices = getInvoices();
return (
<div style={{ display: "flex" }}>
<nav
style={{
borderRight: "solid 1px",
padding: "1rem",
}}
>
{invoices.map((invoice) => (
<Link
style={{ display: "block", margin: "1rem 0" }}
to={`/invoices/${invoice.number}`}
key={invoice.number}
>
{invoice.name}
</Link>
))}
</nav>
</div>
);
}
the data.js is taken from react-router docs https://reactrouter.com/docs/en/v6/getting-started/tutorial
What I’m doing wrong?