【发布时间】:2020-06-21 19:50:05
【问题描述】:
我有一个 hoc withAuth.js 我在其中传递一个组件,第二个参数是当前路由,如果条件失败,它将呈现
const Detail = (props) => {
return(
<>
<div> this is the my account inside ..... </div>
</>
)
};
export async function getServerSideProps({req ,res}) {
// Call an external API endpoint to get posts.
// You can use any data fetching library
// console.log('request object ', req.headers);
// retun the props.api bcoz client side has no access to the baseurl from the server
return {
props:{}
}
}
export default withAuth(Detail, loginRedirectPath);
我的问题是如何将当前路由传递给 hoc
编辑 嗨,我已经通过管理路线历史解决了这个问题
【问题讨论】:
-
“当前路由”是指像example.com/sth这样的整个URL吗?
-
@Hangindev 是 url 或路径