You are not rendering the route components correctly. They should be rendered as JSX, not a reference to the component, on the element
prop. This is a breaking change between versions 5 and 6 of react-router-dom
. Note also that Route
components also no longer take an exact
prop, they are now always exactly matched.
ReactDOM.render(
<Router>
<React.StrictMode>
<Routes>
<Route path="/register" element={<Register />} />
<Route path="/" element={<App />} />
</Routes>
<App />
</React.StrictMode>
</Router>,
document.getElementById('root')
);