我想使用 react-router v4 而不是 v3 更新流星应用程序中的授权。
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-router 文档页面(https://reacttraining.com/react-router/web/example/auth-workflow)中看到了示例。但是还是不知道怎么做。