I have a page that has tabs on it. When I navigate to the page on my app I push to the base app. Ie. "/profile".
This is my profile component, the page that gets called.
<Profile>
<Switch>
<Route exact path={`${path}/feed`} component={Feed} />
{profileId !== null && (
<>
<Route exact path={`${path}/friends`} component={Friends} />
<Route exact path={`${path}/locations`} component={Locations} />
<Route exact path={`${path}/blockedlist`} component={BlockedList} />
</>
)}
<Redirect from={path} to={`${path}/feed`} />
</Switch>
</Profile>
The redirect never gets run. When I remove the check if profileId !== null
then it works. Basically when I load the page it will be at path /profile
then this component should handle the redirect to /feed
on initial load.