Giter Club home page Giter Club logo

Comments (3)

imagine10255 avatar imagine10255 commented on June 10, 2024

@thefubon

Hi, I just created a new Next.js project for testing purposes and successfully deployed it on Vercel.

In the customized Carousel Component, I used 'use client'.

'use client'

import BearCarousel, {BearSlideCard} from 'bear-react-carousel';
import "bear-react-carousel/dist/index.css";

export default function Carousel() {
    // ..... other ignore
    return <BearCarousel data={bearSlideItemData} height="400px" />;
}

Then, I dynamically imported it in the place where it is being used.

import dynamic from 'next/dynamic';

const Carousel = dynamic(() => import('../components/Carousel'), {
  ssr: false,
});

export default function Home() {
    return <div>
        <Carousel/>
    </div>;
}

You can try this example to see if it solves your problem. If you still encounter issues, please provide a git repository that can reproduce the problem.

https://nextjs-bear-carousel-example.vercel.app/

CleanShot 2023-06-26 at 19 53 18@2x

I hope this can help you.

from bear-react-carousel.

thefubon avatar thefubon commented on June 10, 2024

import dynamic from "next/dynamic";
const BearCarousel = dynamic(
() => import("bear-react-carousel").then((mod) => mod), {ssr: false}
);

The problem is that if the files are inside a component, it gives an error on Vercel.

'use client'

import dynamic from "next/dynamic";
import { BearSlideCard } from "bear-react-carousel";

import "bear-react-carousel/dist/index.css";

const BearCarousel = dynamic(
  () => import("bear-react-carousel").then((mod) => mod), {ssr: false}
);

const Carousel = () => {
  const images = [
    { id: 1, imageUrl: "https://dummyimage.com/900x400/dee2e6/6c757d.jpg" },
    { id: 2, imageUrl: "https://dummyimage.com/900x400/dee2e6/6c757d.jpg" },
    { id: 3, imageUrl: "https://dummyimage.com/900x400/dee2e6/6c757d.jpg" }
  ];

  const bearSlideItemData = images.map((row) => {
    return {
      key: row.id,
      children: <BearSlideCard bgUrl={row.imageUrl} />
    };
  });

  return <BearCarousel data={bearSlideItemData} height="400px" />;
}

export default Carousel;

from bear-react-carousel.

imagine10255 avatar imagine10255 commented on June 10, 2024

@thefubon I found the issue you mentioned. After performing the build and deploying it to Vercel, no errors occurred. You can try version 4.0.9 again.

example: https://github.com/imagine10255/nextjs-bear-carousel-example/blob/main/src/components/Carousel2.tsx

from bear-react-carousel.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.