Params is undefined in ItemPage
. I can't seem to see the issue here. Any takers?
Basically trying to create a dynamic path with Link
.
export default function App() {
return (
<Router>
<Switch>
<Route path="/" exact component={Home} />
<Route path="/catalog" component={Catalog} />
<Route path="/about" component={About} />
<Route path="/item/:nm" component={ItemPage}/>
<Route render={() => <h1>404: page not found</h1>} />
</Switch>
</Router>
)}
function Catalog() {
return (
<div className="Catalog">
{Routes.map((route, index) => {
return <p key={index}><Link to={`/item/${route.name}`}> {route.name} </Link></p>
})}
</div>
);
}
const ItemPage = ({match:{params:{nm}}}) => {
return (
<div>
<h1>Item {nm} Page</h1>
<ItemPage name={nm}/>
</div>
)
};