在Meteor中使用react路由器3到4重构身份验证
我想用react-router v4而不是v3更新meteor应用程序中的授权在Meteor中使用react路由器3到4重构身份验证,meteor,react-router-v4,Meteor,React Router V4,我想用react-router v4而不是v3更新meteor应用程序中的授权 Tracker.autorun(() => { const isAuthenticated = !!Meteor.userId(); const pathname = browserHistory.getCurrentLocation().pathname; const isUnauthenticatedPage = unauthenticatedPages.includes(pathname);
Tracker.autorun(() => {
const isAuthenticated = !!Meteor.userId();
const pathname = browserHistory.getCurrentLocation().pathname;
const isUnauthenticatedPage = unauthenticatedPages.includes(pathname);
const isAuthenticatedPage = authenticatedPages.includes(pathname);
if (isUnauthenticatedPage && isAuthenticated) {
browserHistory.replace('/links');
} else if (isAuthenticatedPage && !isAuthenticated) {
browserHistory.replace('/');
}
});
我看到了官方react路由器文档页面()中的示例。但是仍然不知道怎么做。这里有一篇由Meteor Chef撰写的优秀文章,解释了如何使用React路由器V4。他还向您展示了如何处理身份验证