brainhubeu / react-carousel

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)
https://brainhub.eu/
MIT License
1.07k stars 164 forks source link

Cannot update a component while rendering a different component. Probably due to bad setState() #707

Open tramax opened 3 years ago

tramax commented 3 years ago

Describe the bug React issues a warning about bad setState when the Carousel component is used

To Reproduce Steps to reproduce the behavior:

  1. Install 10.2.0
  2. Install react-carousel 2.0.3
  3. Dynamic import the carousel component like so (as NextJS SSR crashes using normal import)
    
    import dynamic from 'next/dynamic';

const Carousel = dynamic( () => import('@brainhubeu/react-carousel'), { ssr: false }, );

5. Use the carousel
6. See error in Chrome console

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
![image](https://user-images.githubusercontent.com/4596834/117849152-96e03480-b2b6-11eb-8e88-153d05c156a5.png)

**Environment**

System: OS: Windows 10 10.0.19042 CPU: (4) x64 Intel(R) Core(TM) i5-7600 CPU @ 3.50GHz
Memory: 1.43 GB / 7.94 GB Binaries: Node: 16.0.0 - C:\Program Files\nodejs\node.EXE
npm: 7.10.0 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 90.0.4430.212 Edge: Spartan (44.19041.906.0), Chromium (90.0.818.56) Internet Explorer: 11.0.19041.1 npmPackages: @brainhubeu/react-carousel: 2.0.3 => 2.0.3

kb1995 commented 3 years ago

@tramax Were you able to fix this error?

rheng001 commented 3 years ago

Facing the same issue

tramax commented 3 years ago

@tramax Were you able to fix this error?

@kb1995 unfortunately not yet 😄 do you face the same problem with NextJS or another stack?

shaunstoltz commented 3 years ago

Same issue... this is a critical bug, make this lib gargbage

shaunstoltz commented 3 years ago

I got this working by used the source and removing all the scss imports as they were bugging in my build environment. Simple import of the index.js file from the src directory here https://github.com/brainhubeu/react-carousel/tree/master/react-carousel/src and the errors about setState were resolved.

tramax commented 3 years ago

I got this working by used the source and removing all the scss imports as they were bugging in my build environment. Simple import of the index.js file from the src directory here https://github.com/brainhubeu/react-carousel/tree/master/react-carousel/src and the errors about setState were resolved.

Hi Shaun. Do you use dynamic import via 'next/dynamic'? Would you be able to post a screenshot or a snippet of your code? Thank you

shaunstoltz commented 3 years ago

Hi, sorry I abandoned this in favor of https://github.com/akiran/react-slick that just seems to work our of the box