【问题标题】:react-router inline render props (Auth0 callback)react-router 内联渲染道具(Auth0 回调)
【发布时间】: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


    【解决方案1】:

    不妨试试

     path="/callback"
    

    如果不是,很可能与使用v2而不是v4有关

    【讨论】:

      猜你喜欢
      • 2022-01-12
      • 2018-02-15
      • 2018-12-17
      • 2017-12-03
      • 2023-03-09
      • 2020-12-18
      • 2016-02-22
      • 2019-01-02
      • 2016-06-13
      相关资源
      最近更新 更多