Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'component' does not exist on type

Tags:

react-router

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
like image 695
Turhan Ergene Avatar asked Sep 05 '25 16:09

Turhan Ergene


1 Answers

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 />} />
like image 116
nanoTitan Avatar answered Sep 08 '25 23:09

nanoTitan