Unable to render data on webpage | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Unable to render data on webpage

Hi, can you help me figure out what's the issue here: https://stackoverflow.com/questions/74455230/uncaught-error-publicroute-is-not-a-route-component-all-component-children I'm trying to render <PublicRoute> and </PrivateRoute> components but the webpage is blank, even though there're no errors or warnings.

18th Nov 2022, 12:27 PM
Asha
Asha - avatar
3 Answers
+ 4
Which react-router version are you using? V6?
14th Jan 2023, 5:59 PM
Kelvin Paul
Kelvin Paul - avatar
+ 1
Kelvin Paul yes it's version 6, as mentioned in the problem statement too. This issue has been unresolved for quite a while. I wonder what am I missing in new updates?
21st Jan 2023, 2:20 PM
Asha
Asha - avatar
+ 1
Asha // definition expert const PrivateRoute = () => { const [auth, setAuth] = useState(false); useeffect(()=> { // check your auth // Then set setAuth(true|false); }, []); return auth ? props.children : <>No access</> } //Usage <Routes> <Route path={/**/} element={<PrivateRoute><MyRoute/><PrivateRoute>} /> </Routes> I think this might work
21st Jan 2023, 8:01 PM
Kelvin Paul
Kelvin Paul - avatar