DEV Community

Rachael Mathew
Rachael Mathew

Posted on

Authenticated Routes inside <Routes>

I am trying to created an Authenticated route(/login and /signup) that will only appear if a user is not logged/signed up into a website.

I am following along with the video here.

I have set my AuthRoute as such:
Image description

I have added my AuthRoute to App.js like this:
Image description

But I get the error: [AuthRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

I have tried changing the AuthRoute in App.js to
<Route element={<AuthRoute exact path="/signup" authenticated={authenticated} element={<Signup/>} />}/>

But now I get the error: No routes matched location "/signup"

Top comments (0)

Top Posts from the React Ecosystem

1. Changes In The Official React Documentation

The former React Docs Beta has been officially released as the updated React documentation at after years of hard work and refinement. Check out the brand new React Docs: What’s New in the Updated React Docs

2. CRA's Time is Over

React developer team has removed create-react-app (CRA) from official documentation rendering it no longer the default setup method for new projects. The bulky setup, slow, and outdated nature of CRA led to its removal: create-react-app is officially dead

3. How to Fetch Articles for Your Portfolio

Integrate the articles of your profile into your personal portfolio with either React, Vue, or Next.js by following these simple steps. It outlines how to include frontend to pull the information and correctly utilizes the API: How to Fetch Your Articles for Your Portfolio with React