react-multi-carousel: error - TypeError: Object prototype may only be an Object or null: undefined in Next.Js 13
Describe the bug
Trying to use the carousel in a server side component in Next Js 13.1.2 gives the below error and won’t render the component.
error - node_modules\react-multi-carousel\lib\types.js (1:262) @ d
error - TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
at extendStatics (webpack-internal:///(sc_server)/./node_modules/react-multi-carousel/lib/types.js:10:
To Reproduce: “react-multi-carousel”: “^2.8.2”, ` const FeaturedPosts = () => { const featuredPosts = await getFeaturedPosts()
<Carousel ssr infinite customLeftArrow={<CustomLeftArrow />} customRightArrow={<CustomRightArrow />} responsive={responsive} itemClass=“px-4” > {dataLoaded && featuredPosts.map((post, index) => ( <FeaturedPostCard key={index} post={post} /> ))} </Carousel> };`
Expected behavior Should render the page and the carousel.
Additional context If i use the “use client” directive to render the page using a useEffect for the posts the page renders fine.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 10
- Comments: 17 (1 by maintainers)
added ‘use client’ to the top of the component file and it seems to work
Not yet Tim I had to “use client” to get it to work.
What if you want your component to be server-side rendered for SEO purposes for example ? ‘use client’ won’t solve it for that use case
This fixed it for me on Remix
https://github.com/YIZHUANG/react-multi-carousel/issues/314#issuecomment-1031216620
Same here. Won’t render, breaks build with NextJs 13.2