close

[Fixed] Error: [PrivateRoute] is not a component. All component children of must be a or

Today We are Going To Solve Error: [PrivateRoute] is not a component. All component children of must be a or in reactjs. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix Error: [PrivateRoute] is not a component. All component children of must be a or Error?

  1. How to Fix Error: [PrivateRoute] is not a component. All component children of must be a or Error?

    To Fix Error: [PrivateRoute] is not a component. All component children of must be a or Error just set your router component. To solve this error you have to just set your router component to element prop as you can see in the below code. So just set your router component and your error will be solved. Thank you! <Routes> <Route exact path="/" element={<Home />} /> <Route path="/about" element={<About />} /> <Route path="/dashboard" element={<Dashboard />} /> </Routes>

  2. Error: [PrivateRoute] is not a component. All component children of must be a or

    To Fix Error: [PrivateRoute] is not a component. All component children of must be a or Error just replace some code. First of all go to the DefaultPage and after it use <Route index element={} /> to replace the <Navigate to={window.location.pathname + '/kanban'}/>. Just replace it and the error will be solved. This work for me. Try this.

Solution 1 : set your router component

To solve this error you have to just set your router component to element prop as you can see in the below code. So just set your router component and your error will be solved. Thank you!

<Routes>
  <Route exact path="/" element={<Home />} />
  <Route path="/about" element={<About />} />
  <Route path="/dashboard" element={<Dashboard />} />
</Routes>

Solution 2 : replace some code

First of all go to the DefaultPage and after it use <Route index element={} /> to replace the

<Navigate to={window.location.pathname + ‘/kanban’}/>. Just replace it and the error will be solved. This work for me. Try this.

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read This Solutions

Leave a Comment