Open tomm1996 opened 1 year ago
up
Any updates on this? We are updating to react 18, and this is causing us to have to force any elements that have a react swiper to be rendered client side. If we can, we would love to be able to render them on the server. There is no data in them that requires loading on the client.
same here, let's go HEROS!
https://www.youtube.com/watch?v=imhdh4xCh7I
followed it and it worked just fine 🚀
"use client";
import Image from "next/image";
import { Swiper, SwiperSlide } from "swiper/react";
import { Navigation, Pagination } from "swiper/modules";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import { images } from "@/lib/images";
export default function Page() {
return (
<section className="py-12">
<div className="container">
<Swiper
navigation
pagination={{ type: "bullets", clickable: true }}
modules={[Navigation, Pagination]}
onSwiper={(swiper) => console.log(swiper)}
className="h-[500px] w-full rounded-lg"
>
{images.map((image) => (
<SwiperSlide key={image.alt}>
<div className="flex h-full w-full items-center justify-center">
<Image
src={image.src}
alt={image.alt}
className="block h-full w-full object-cover"
/>
</div>
</SwiperSlide>
))}
</Swiper>
</div>
</section>
);
}
// @/lib/images.ts
import first from "@/public/slides/first.jpg";
import second from "@/public/slides/second.jpg";
import third from "@/public/slides/third.jpg";
import fourth from "@/public/slides/fourth.jpg";
export const images = [
{ src: first, alt: "first" },
{ src: second, alt: "second" },
{ src: third, alt: "third" },
{ src: fourth, alt: "fourth" },
];
Up
@felipe-muner swiper-react will be deprecated. This is about swiper-element
Up 👍
any update on this?
up
For anyone trying to use swiper in react, suggest to migrate to embla that's used under the hood in shadcn https://github.com/davidjerleke/embla-carousel
up
up
up
Clear and concise description of the problem
In a
npx create-next-app@latest
boilerplate add this componentYou will receive this error:
Suggested solution
Alternative
No response
Additional context
https://lamplightdev.com/blog/2019/07/20/how-to-server-side-render-web-components/ https://nextjs.org/docs/getting-started/react-essentials#third-party-packages
Validations
Would you like to open a PR for this feature?