【问题标题】:Component definition is missing display name when using withAuthenticationRequired使用 withAuthenticationRequired 时组件定义缺少显示名称
【发布时间】:2021-10-01 23:20:24
【问题描述】:

我有以下编译错误

组件定义缺少显示名称 react/display-name

我的代码:

import React from "react";
import {withAuthenticationRequired} from "@auth0/auth0-react";

function MyComponent () {
    return (<div>Hello</div>);
}

export default withAuthenticationRequired(MyComponent, {
    // Show a message while the user waits to be redirected to the login page.
    onRedirecting: () => <div>Redirecting you to the login page...</div>,
});

我尝试了类似问题的解决方案,但没有奏效。禁用 eslint react/display-name 选项不是我所期望的。

【问题讨论】:

    标签: reactjs auth0


    【解决方案1】:

    在 Github 上的 issue 中回答:https://github.com/auth0/auth0-react/issues/282#issuecomment-928051777

    export default withAuthenticationRequired(MyComponent, {
        onRedirecting: function OnRedirectingComponent() {
          return <div>Redirecting you to the login page...</div>
        },
    });
    

    【讨论】:

      猜你喜欢
      • 2020-06-19
      • 1970-01-01
      • 2021-12-13
      • 2019-03-30
      • 1970-01-01
      • 1970-01-01
      • 2020-07-28
      • 2022-06-17
      相关资源
      最近更新 更多