To fix ‘Matched leaf route at location "/" does not have an element’ error with React Router 6, we set the element
prop to the component we want to render when we go to the URL.
For instance, we write
<Route path="/" element={<Home />}></Route>;
to add a Route
component with the element
prop set to the Home
component.
Then when we go to /, we see the Home
component rendered.