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

WindowVirtualizer is not properly work with static exported nextjs app: "Uncaught TypeError: X is not a function #322

Closed
Monstass opened this issue Jan 11, 2024 · 5 comments · Fixed by #324
Assignees

Comments

@Monstass
Copy link

Monstass commented Jan 11, 2024

WindowVirtualizer does not work properly with static exported nextjs app.
Rendered items are not clickable and in console we can see error "Uncaught TypeError: X is not a function".

To Reproduce
Build and start nextjs app by using 'output: "export"' flag in next config.

import { WindowVirtualizer } from "virtua";

const MainPage = () => {
  const length = 200;

  return (
    <WindowVirtualizer>
      {Array.from({ length: length }).map((_, i) => (
        <div key={i}>
          <a href="http:https://www.google.com">{`index - ${i}`}</a>
        </div>
      ))}
    </WindowVirtualizer>
  );
};

export default MainPage;

Clicking on links has no effect (other events neither) after scroll down for few pixels.
Console output will be like this on every scroll event:

image

Codesandbox with exmaple: https://codesandbox.io/p/devbox/virtua-windowvirtualizer-bug-hj8w6c

Expected behavior
No uncaught errors and clickable items.

Platform:

  • virtua: 0.20.3
  • next: 13.5.4
  • react: 18

Additional context
And, yeah, rolling back to v0.17.6 helped me.

@inokawa
Copy link
Owner

inokawa commented Jan 11, 2024

Could you make a reproduction code or give me more detailed information?

@Monstass
Copy link
Author

@inokawa of course I just accidentally pressed the enter button, my bad :D already updated

@inokawa
Copy link
Owner

inokawa commented Jan 11, 2024

Thank you for the information!
It can be reproduced. And it looks like a SWC's minify issue (like vercel/next.js#58959 ?) because setting swcMinify: false to nextconfig to use terser solved the error.

https://nextjs.org/docs/architecture/nextjs-compiler#minification

@Monstass
Copy link
Author

setting swcMinify: false to nextconfig to use terser solved the error.

Yeah, it is. Thank you for tip.

By the way, without setting swcMinify: false on 14.0.4 and canary next releases the application crashes completely, but, again, not with [email protected]

@inokawa
Copy link
Owner

inokawa commented Jan 12, 2024

Probably fixed in 0.20.4.

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

Successfully merging a pull request may close this issue.

2 participants