DEV Community

Discussion on: How to create multi-step forms in React?

Collapse
 
devalo profile image
Stephan Bakkelund Valois

I'm getting a
SyntaxError: Cannot use import statement outside a module
module.exports = require("react-step-builder");

When trying to use it inside a React Next container.
Error happens as I'm importing the module into my component.

Collapse
 
sametweb profile image
Samet Mutevelli

Hello Stephan,
Although I am happy to help you with that, I am not very confident with my Next.js knowledge.
I researched the error message, and obviously, it helps in some cases if you add "type": "module" in your package.json file.
If that doesn't solve your issue, could you maybe reproduce the issue on codesandbox or share the repo with me so I can take a better look?

Collapse
 
krankj profile image
Sudarshan K J

I had the same problem. You can get around it by using Dynamic Imports in Next.js
Refer to the 3rd comment by 'acelaya' here: github.com/asyncapi/asyncapi-react... on how to get around this issue.

Collapse
 
sametweb profile image
Samet Mutevelli

This problem is solved with version @2.0.11