在NextJs中配置Auth0提供程序时出错

时间:2020-09-03 22:37:09

标签: reactjs typescript next.js auth0

我正在尝试在我的Nextjs应用中使用Auth0。为此,我需要将组件包装在Auth0Provider中,然后开始使用它。由于某种原因,我收到此错误:

Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.

我的_app.tsx

import GlobalStyles from "../styles/Global";
import { Auth0Provider } from "use-auth0-hooks";

function MyApp({ Component, pageProps }) {
  return (
    <>
      <Auth0Provider
        domain="My domain here"
        redirectUri={window.location.origin}
        clientId="My secret here"
      >
        <Component {...pageProps} />
      </Auth0Provider>

      <GlobalStyles />
    </>
  );
}

export default MyApp;

有人知道发生了什么事吗?

编辑:删除了异步,它也无法正常工作。

Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
    in Home (at _app.tsx:12)
    in Context.Provider
    in UserProvider
    in Context.Provider
    in Auth0Provider (at _app.tsx:7)
    in Fragment
    in MyApp (at _document.tsx:13)
    in Context.Provider
    in Context.Provider
    in StyleSheetManager
    in Unknown
    in Context.Provider
    in Context.Provider
    in Context.Provider
    in Context.Provider
    in AppContainer

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Source
pages/_document.tsx (11:8) @ Object.ctx.renderPage

   9 | try {
  10 |   ctx.renderPage = () =>
> 11 |     originalRenderPage({
     |    ^
  12 |       enhanceApp: (App) => (props) =>
  13 |         sheet.collectStyles(<App {...props} />),
  14 |     });
Call Stack
Function.getInitialProps
../../pages/_document.tsx (66:33)

完整错误日志

0 个答案:

没有答案