【发布时间】:2021-08-20 10:37:07
【问题描述】:
我从后端获取了一个数据,其中包含组件名称,它们应该传递给 HOC 和路由
import Users from './Users/Users.lazy';
........
// RequireAuth is the HOC
<Switch>
<Route path="/home" component={RequireAuth(Home)} />
{(props.pagesData.length) && props.pagesData.map(item =>
<Route exact path={`${item.PagePath}`} component={RequireAuth(`${item.PageName}`)} />
)}
<Redirect to="/home" />
</Switch>
如何将Users(由item.PageName提供)之类的字符串转换为组件。
谢谢
【问题讨论】:
标签: reactjs react-router react-hooks components