2

I had tried to run Next.js project with next start(next build was ok and it works with next dev) and saw some error messages in browser console:

TypeError: e is undefined
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
Error rendering page:  TypeError: t is undefined

I've watched that link in error message and it says:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: [missing argument].[missing argument]

But I still don't understand where is the problem. Is there a way to disable code minification in next build and view a full traceback?

mihett05
  • 53
  • 2
  • 6

1 Answers1

3
  • The reason why it's doing that in prod and not dev is because nextjs will only check types on a production build (as far as I'm aware).
  • I think I've seen that error before when you pass a string or an invalid value to renderToString from react-dom/server.

The reason that's most likely happening is because nextjs will by default import all your exports and render the page for you, so in this case I don't believe you can just export named or default exports at will, I think it has to be a default export for the page component itself, while all the getStaticProps and other exports should be named.

To fix your issue just change export Example to export default Example.

  • As I seen next.js checks types while `next build` which my project successfully complete. I don't use getStaticProps and another next.js functions for component. All pages and components exports were made by `export default`. But I found in some components I have named exports of typescript interfaces, can it cause that errors? – mihett05 Aug 14 '21 at 12:38
  • I'm really not sure because it depends on how nextjs is taking your exports and feeding it into react's render functions. I'd suggest remove everything from that page except for the main default export, if it works then you know it's the typescript interfaces that's breaking it. Alternatively keep adding the stuff you have till it breaks again then you can pinpoint what it is. Something you're exporting is causing it. Can you show what exactly you're exporting from that page? –  Aug 14 '21 at 12:44
  • That error was on every page in my project, so I realized that error in Layout. After some tries of importing stuff in index.tsx I realized that problem was in one library which interacts decorators. I removed that library and code that using it and it works. Thanks! – mihett05 Aug 14 '21 at 14:58