【发布时间】:2019-01-10 13:57:54
【问题描述】:
使用 react-router v2.4.0 并尝试将 Auth0 的回调路由到 Auth0 指定的特定函数和组件。
这是我的路由器代码。 没有发生任何事情,似乎不支持 props 或 {location}。我成功进行内联渲染的唯一方法是简单地设置一个 render={myTest()} 路由。但是一直无法获取和传递 props 参数或任何东西。
是因为我使用的是 react-router v2.4.0 吗?不确定我是否已准备好进行 v4 迁移,因为现在这样做可能会花费我相当长的时间。
有什么想法吗?
import Auth from './users/authv9/Auth';
import Callback from './users/authv9/Callback';
const auth = new Auth();
const handleAuthentication = ({location}) => {
console.log('handleAuthentication #1');
console.log(location);
if (/access_token|id_token|error/.test(location.hash)) {
console.log('handleAuthentication #2');
auth.handleAuthentication();
}
}
ReactDOM.render((
<Router history={browserHistory}>
<Route path="/" component={App} auth={auth}>
<IndexRoute component={Home} />
<Route path="callback" render={(props) => {
handleAuthentication(props);
<Callback {...props} />
}}/>
【问题讨论】:
标签: react-router render inline auth0