react-carousel icon indicating copy to clipboard operation
react-carousel copied to clipboard

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

Open tramax opened this issue 3 years ago • 7 comments

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 },
);
  1. Use the carousel
  2. See error in Chrome console

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

Screenshots image

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

tramax avatar May 11 '21 16:05 tramax

@tramax Were you able to fix this error?

kb1995 avatar May 17 '21 13:05 kb1995

Facing the same issue

rheng001 avatar May 20 '21 02:05 rheng001

@tramax Were you able to fix this error?

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

tramax avatar May 23 '21 12:05 tramax

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

shaunstoltz avatar Jun 10 '21 17:06 shaunstoltz

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.

shaunstoltz avatar Jun 10 '21 18:06 shaunstoltz

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

tramax avatar Jun 17 '21 13:06 tramax

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

shaunstoltz avatar Jun 17 '21 15:06 shaunstoltz