Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing an Error "Cannot access .propTypes on the server" after updating to Next.js v13.4.12 #192

Open
DystopianDisco opened this issue Jul 30, 2023 · 7 comments

Comments

@DystopianDisco
Copy link

Bug:

On loading the guides or the blog pages getting an 'Unhandled Runtime Error'

Error: Cannot access .propTypes on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.

Screen Shot 2023-07-31 at 6 56 23 AM

This occurs after updating next.js from v13.3.2-canary.13 to Next.js v13.4.12. The rest of the app works - how to resolve?

@tyrozz
Copy link

tyrozz commented Aug 3, 2023

I also had this issue. I guess it is related to contentlayer related pages. You can try to create a client component to render the blog post details and use this component in the blog post detail page. Same logic for other mdx related pages.

@shadcn
Copy link
Collaborator

shadcn commented Aug 3, 2023

This is a known issue. If you have components like <Foo.Bar /> it does not work with Contentlayer.

@jbryandev
Copy link

The culprit is the <Image> tags in a few of the mdx content files. I fixed by marking them as jsx in the markdown files. For example:

```jsx
<Image
  src='/images/blog/blog-post-4.jpg'
  width='718'
  height='404'
  alt='Image'
/>
```

@choubari
Copy link

choubari commented Sep 6, 2023

I had the same error yesterday, and found already an issue created in the Contentlayer repo.

It looks that the props passed to Next Image are not read properly by Contentlayer with Nextjs 13.4, either downgrade to 13.3 or change the way you pass Image component on your mdx-components file

import Image, { ImageProps } from "next/image"

const components = {
  // Image,
  Image: (props: ImageProps) => <Image {...props} />,
}

Originally posted by @jdharms in contentlayerdev/contentlayer#506 (comment)

@jbryandev
Copy link

I haven't tested it out, but that seems like the best solution, as it appears to maintain complete functionality of the Next Image component. I hadn't had a chance to test out my prior solution to see if the Image component was functioning as intended, and I think using a pure <img> tag would lose the benefits provided by the Next Image component. Thanks for posting @choubari!

@vagnermaltauro
Copy link

i opened a PR with the correction
#212

@soulbliss
Copy link

I had the same error yesterday, and found already an issue created in the Contentlayer repo.

It looks that the props passed to Next Image are not read properly by Contentlayer with Nextjs 13.4, either downgrade to 13.3 or change the way you pass Image component on your mdx-components file

import Image, { ImageProps } from "next/image"

const components = {
  // Image,
  Image: (props: ImageProps) => <Image {...props} />,
}

Originally posted by @jdharms in contentlayerdev/contentlayer#506 (comment)

This solution worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants