Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'preload' of undefined #44

Open
arishoham opened this issue Jan 3, 2023 · 1 comment
Open

Cannot read property 'preload' of undefined #44

arishoham opened this issue Jan 3, 2023 · 1 comment

Comments

@arishoham
Copy link

With nextjs v13.1.7-canary.3, the 'preload' function no longer exists on next/dynamic components with {ssr: false}, causing an error Cannot read property 'preload' of undefined

@aitorllj93
Copy link

aitorllj93 commented Jan 12, 2023

Setting ssr to true also doesn't seem to be working as expected as the preloaded component still required to wrap the tests inside act/waitFor.

Although not a really clean solution, this can work as a temporary patch (inside the createFactory function):

let c = () => null;

const promiseLoader = loader().then((comp) => {
  c = typeof comp === 'function' ? comp : comp.default || (() => null);
});

mockInitializers.push(() => promiseLoader);

return (props) => c(props);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants