YIZHUANG / react-multi-carousel

A lightweight production-ready Carousel that rocks supports multiple items and server-side rendering with no dependency. Bundle size 2kb.
MIT License
1.3k stars 293 forks source link

NextJS 13 #388

Open maurorpo opened 1 year ago

maurorpo commented 1 year ago

I found this issue when using RMC with Next Js 13

Imagen de WhatsApp 2023-04-21 a las 15 45 46 Imagen de WhatsApp 2023-04-21 a las 15 46 45

DevDugg commented 1 year ago

I had the same problem. You should use the "use client" declaration on top of the file, where you import the Carousel component Like this

maurorpo commented 1 year ago

i try but this show me the console

image

DevDugg commented 1 year ago

When you are mapping in React or Next, you must always provide a keyattribute to the element that you're returning. It should look like this:

array.map((item, index) => ( <div key={index}>...</div> ));

It is necessary to do that, because React needs the key to recognise the elements during re-renders.

You can use any number instead of index, just make sure it is unique.

You can read more in the official docs

maurorpo commented 1 year ago

thanks for answer, but that is not the error

image

i fixed that warning but i hava this ( image )

DevDugg commented 1 year ago

Same answer, use the use client declaration on top of the file which gives the error

SaerwenLis commented 1 year ago

Hello, I have the same problem, but I need to render the carousel on server, any other way to fix it?

DevDugg commented 1 year ago

@SaerwenLis What carousel are you using? It is possible to render it on server if the package you're using supports SSR.

yjleeinkr commented 1 year ago

@SaerwenLis If you need to render it on server, how about hybrid rendering - making carousel separatlely on client component by using 'use client' then just importing on server components/pages? I'm not sure but hope it can help!

SaerwenLis commented 1 year ago

@yjleeinkr I already solved it ty

sqle157 commented 1 year ago

@SaerwenLis How did you solve it? I run into the same problem too and I'm trying to figure what's happening

jdrew-byte commented 1 year ago

It does support sever-side, but I prefer using the client because you have to really on the headers with device-agent which isn't very accurate like basic media queries.

naeem23 commented 1 year ago

I had the same problem. You should use the "use client" declaration on top of the file, where you import the Carousel component Like this

thanks for the solution.

Arthur7711 commented 1 year ago

Does ssr working for you ? This lib not working without "use client" and giving you an option ssr={true} which not working cause we can use it only by "use client" how to make it work in ssr any ides ?)

etabard commented 9 months ago

You should use ssr with the deviceType parameter