We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 372e6d7 commit f715bbeCopy full SHA for f715bbe
src/utils/nonce.js
@@ -1,7 +1,18 @@
1
const isServer = typeof window === `undefined`;
2
3
+function isAsyncComponentFactory(componentOrFactory) {
4
+ return typeof componentOrFactory === `function`;
5
+}
6
+
7
+function resolveComponent(componentOrFactory) {
8
+ if (isAsyncComponentFactory(componentOrFactory)) {
9
+ return componentOrFactory().then(componentModule => componentModule.default);
10
+ }
11
+ return componentOrFactory;
12
13
14
export function makeNonce({ component, hydrationPromise }) {
15
if (isServer) return component;
16
- return () => hydrationPromise.then(() => component);
17
+ return () => hydrationPromise.then(() => resolveComponent(component));
18
}
0 commit comments