close

[Solved] Matched leaf route at location “/” does not have an element

I am facing the following error while Using Route: Matched leaf route at location “/” does not have an element in ReactJS. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.

How Matched leaf route at location “/” does not have an element Error Occurs?

I am using Route and I am facing the following error.

Matched leaf route at location "/" does not have an element

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve Matched leaf route at location “/” does not have an element Error?

  1. How To Solve Matched leaf route at location “/” does not have an element Error?

    To Solve Matched leaf route at location “/” does not have an element Error From V6 you can not use the component prop anymore. It must be replaced with the element So Just Replace this: <Route path=”/” component={HomeScreen} /> with this: <Route path=”/” element={<HomeScreen/>} /> Now, Your error must be solved. Thank You.

  2. Matched leaf route at location “/” does not have an element

    To Solve Matched leaf route at location “/” does not have an element Error From V6 you can not use the component prop anymore. It must be replaced with the element So Just Replace this: <Route path=”/” component={HomeScreen} /> with this: <Route path=”/” element={<HomeScreen/>} /> Now, Your error must be solved. Thank You.

Solution 1: Replace component with the element

From V6 you can not use the component prop anymore. It must be replaced with the element So Just Replace this:

<Route path="/" component={HomeScreen} />

with this:

<Route path="/" element={<HomeScreen/>} />

Now, Your error must be solved. Thank You.

Solution 2: Wrap your Component

You need to wrap your component just like {<Home/>} instead of {Home} Just like this.

<Route path="/" component={ <Home/> } />

And now, Your error will be solved. Thanks.

Summary

It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

2 thoughts on “[Solved] Matched leaf route at location “/” does not have an element”

Leave a Comment