Issues when using together with Next.js
See original GitHub issueAfter trying several ways of using asscroll v2, I still haven’t found a way to successfully use it in Next.js. In versions prior to v2, this worked:
// _app.js
useEffect(() => {
const ASScroll = require("@ashthornton/asscroll").default;
const sc = new ASScroll();
sc.enable();
const handleRouteChange = () => {
setTimeout(() => {
sc.onResize(window.innerWidth, window.innerHeight);
}, 500);
};
router.events.on("routeChangeComplete", handleRouteChange);
}, []);
(The onResize was needed to calculate the new page height)
After upgrading to v2, though, I keep getting the TypeError: ASScroll is not a constructor
error. I also tried to import it at the top (native and via next/dynamic), but then Webpack throws a ReferenceError: self is not defined
error.
Any help is appreciated!
Thanks in advance 😃
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Next.js: The Good, Bad and Ugly - An Idiosyncratic Blog
When to use Next.js? Issues with Next.js; CSS Modules; Automatic Static Optimization, but only if you do this; Share data between getStaticPaths ...
Read more >Basic Features: ESLint - Next.js
Next.js provides an integrated ESLint experience by default. These conformance rules help you use Next.js in the optimal way.
Read more >Advanced Features: Next.js Compiler
js Compiler, written in Rust using SWC, allows Next.js to transform and minify your JavaScript code for production. This replaces Babel for individual...
Read more >Blog - Next.js 13
Next.js 13 introduces layouts, React Server Components, and streaming in the app directory, as well as Turbopack, an improved image ...
Read more >Migrating from Create React App - Next.js
Updating package.json and dependencies · Remove react-scripts (but keep react and react-dom ). If you're using React Router, you can also remove react-router-dom ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @tienuur , this must be a quirk with Nextjs and custom attributes. Glad you found a solution!
I found a solution: I have to explicitly state
asscroll-container="true"
to make it work.