我有一个带有选项卡的页面。当我从我的应用程序导航到该页面时,我会将其推送到基本应用程序中。例如:“/profile”。
这是我的个人资料组件,也就是被调用的页面。
<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>
重定向没有运行。当我删除检查
profileId !== null
时,则可以正常工作。基本上,当我加载页面时,它将位于路径 /profile
,然后此组件应在初始加载时处理重定向到 /feed
。
...
)一个React元素数组(例如路由),而不是将它们包装在片段中。 - DBS