我目前正在尝试将加载组件纳入使用NextJS构建的网站中。我想使用Suspense来显示加载屏幕,无论是在刷新页面还是更改路由后。
以下是我的代码:
import Head from 'next/head'
import { Loader } from '../components/loader'
const { Suspense } = require('React')
function MyApp({ Component, pageProps }) {
return (
<>
<Suspense fallback={<Loader />}>
<Head>
.... some codes such as meta tags, title tags ....
</Head>
<Component {...pageProps} />;
</Suspense>
</>
)
}
我的问题是我遇到了一个错误,显示ReactDOMServer目前不支持Suspense,但我希望使用Suspense来在我的页面上启用加载屏幕。就像这个网站一样。