Skip to content
Advertisement

Component is not rendering even after routing | React JS | React Router v6

For now i have two components. What i want to do is that after a successful login i will redirect the user to a homepage. But when i am trying to do that its not happening . Although the routes are changing in the url but the previous component is not going and overlapping with the new component. I have tried other ways too but no good. Any suggestion will be of great help Before signing

After signing and first component is not going

My Code:

JavaScript

Advertisement

Answer

JavaScript

This code means “Render component if url is domain/api/v1/app/test”

So you need to wrap your conditional rendering logic with a parent component

example

Main.js:

JavaScript

LoginPage.js:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement