next.js: TypeError: Object(...) is not a function

There is a strange error occurring, I have created a HOC to check if the user is logged in or not and then proceed as follows.

return <Component user = {user} {...props} />

The error is probably about {... props}, has anyone ever dealt with this problem?

One thing that happens is that this error only appears when I’m running yarn build && yarn start

captura de tela 2018-10-29 as 15 34 58

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

unrelated, sorry. I was using hooks with the default react 16. npm i react@next react-dom@next fixed this.

Also having this issue. Everything works locally, only fails once I try to deploy to now.sh. The build step passes, but when I hit my index page, I get this error. I am also using react hooks.

@timneutkens unfortunately it’s not the space problem this started to become common in version 7.0.2

@afzalzbr i didn’t use HOC anymore, i had to use next-auth context. This article helped me out [here](https://blog.logrocket.com/how-to-use-nextauth-js-for-client-side-authentication-in-next-js/)

I was getting this error using Next.js and for me it was caused by trying to destructure a function that didn’t exist in an npm module. eg import { loadRecaptcha } from "recaptcha-v3"; instead of import { load } from "recaptcha-v3"; and then trying to run it in an async function.