0
我想使用react-router v4而不是v3来更新meteor应用程序的授权。在流星中使用react-router 3到4的重构认证
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('/');
}
});
我见过官方反应路由器文档页面(https://reacttraining.com/react-router/web/example/auth-workflow)的例子。但仍然不知道要做到这一点。