Why do I get this error when I declare a "component" property in "Route";
Property 'component' does not exist on type 'IntrinsicAttributes & (PathRouteProps | LayoutRouteProps | IndexRouteProps)'.
import { Routes, Route } from 'react-router-dom'
import './App.css'
import HomePage from './pages/HomePage'
function App() {
return(
<div>
<Routes>
<Route path="/" component={HomePage}/>
</Routes>
</div>
)
} ``` The problem might be; because I dont use 'exact path="/"' that might also give an error
With the upgrade of react-router-dom to version 6.0, certain properties have changed. The syntax you are using will work fine for version 5.0. To update to v6, make this change to your code:
<Route path="/" element={<HomePage />} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With