Need help with <Route>
Hello, I'm learning react by following a video, however I did everything the same but I came across this error below. Since the video is about 1 year ago, I'm guessing that the react has updated by then since "<Routes>" was never mentioned. How do I fix this?
"Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>."
9 Replies
the error suggests this
as a first step at least
Hmmm, ok it dose work but something is off. Here is what I'm seeing.
And this is what it suppose to look like in the video
I think maybe you're missing somewhere where the nested route is showing? Though I also don't speak React, I just read the error message 🤷
hmmm, I guess since react updated since the video, I'll need to fixed it somehow XD
again, take what I say with a grain of salt, I've never used react, just Vue and Svelte and one misguided drunken night with Angular way back in the day
All good, I gotten pass step 1 . Thanks for help 🙂
I think you also need router:
I haven't done class based React, I have only done functional, but here is my App.js in my GitHub repo from a Brad Traversy course: https://github.com/Kernix13/house-marketplace/blob/main/src/App.js
GitHub
house-marketplace/App.js at main · Kernix13/house-marketplace
React app from Brad Traversy Udemy course using Firebase for DB storage. - house-marketplace/App.js at main · Kernix13/house-marketplace
I fixed it. It all works now 🙂