react-scroll-into-view not working next.js app
dhavalveera opened this issue · 2 comments
Hello,
I am trying to use this useful npm package with my Next.js
based App but when I run the code, it throws an exception that SyntaxError: Cannot use import statement outside a module
for your reference & better understanding, I am attaching the screenshot of the exception/error I am encountering when using it in Next.js - a React.js Framework
please help me in this case.
Hi @dhavalveera
I found a similar issue in another library and there is a solution for this - use dynamic import without sso (as react-scroll-into-view works only in a browser).
I've made codesandbox for you where it actually works - https://codesandbox.io/s/focused-silence-ylc3e?file=/pages/index.js
Hi @dhavalveera I found a similar issue in another library and there is a solution for this - use dynamic import without sso (as react-scroll-into-view works only in a browser).
I've made codesandbox for you where it actually works - https://codesandbox.io/s/focused-silence-ylc3e?file=/pages/index.js
Thank you sir for your quick help and now it is working perfectly fine for me. Thanks a lot @dominikbulaj