react-router - react-router 内联渲染道具(Auth0 回调)
问题描述
使用 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} />
}}/>
解决方案
也许试试
path="/callback"
如果不是,很可能与使用 v2 而不是 v4 有关
推荐阅读
- postgresql - PostgreSQL 12 docker 容器无法在特定架构上重新启动
- javascript - How to use Puppeteer on NODE server and get the results on frontend HTML page?
- python - 使用 pandas crosstab 和 pandas_ml ConfusionMatrix 创建混淆矩阵的问题
- javascript - 如何在 HTML 中输出带有参数 onclick 的函数的值?
- mysql - MYSQL查询匹配的3个表
- javascript - 无法在画布元素中绘制弧(圆)
- python - Selenium 脚本在逐行执行时有效,但在完全执行时无效
- kotlin-coroutines - 长协程体的成语(轻量级设计模式)?
- python - 我可以接收有关连接到我的服务器的新 IP 地址的通知吗?
- php - 如何反转这个json