Skip to content
Advertisement

Link routes in react changes the link but nothing is changing in the content of the page

I’m trying to make a navbar using react , but although the link has changed , the content never being changed !

routes in my App.js :

JavaScript

Home.js file , the content “Home” doesn’t appear , although the link changed:

JavaScript

Also the content of Blog.js file doesn’t appear “same as Homel.js”:

JavaScript

code of navbar Navbar.js using bootstrap :

JavaScript

Layout.js:

JavaScript

Advertisement

Answer

Nothing is rendered because you are not correctly using the Route component’s element prop to render the routed components. In react-router-dom@6 gone are the component and render and children render function props, replaced by a single element prop taking a ReactElement, a.k.a. JSX.

Route

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement